diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-21 18:11:51 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2013-08-21 18:11:51 -0700 |
commit | b67fecd0f178ea70e4fa9823c408e52437426403 (patch) | |
tree | 165cc7db3b12393d55c99b05b23cb7c64c20567d /src | |
parent | f315253ff7c5f4074f61a079308db45452be75db (diff) | |
parent | 6634d82f74b71dd36ca1ecceea08b4ad79335da0 (diff) | |
download | scala-b67fecd0f178ea70e4fa9823c408e52437426403.tar.gz scala-b67fecd0f178ea70e4fa9823c408e52437426403.tar.bz2 scala-b67fecd0f178ea70e4fa9823c408e52437426403.zip |
Merge pull request #2852 from retronym/ticket/1980-warning
SI-1980 A lint warning for by-name parameters in right assoc methods
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index b8b06f3082..5929cab1d1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1376,6 +1376,16 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans member.typeParams.map(_.info.bounds.hi.widen) foreach checkAccessibilityOfType } + private def checkByNameRightAssociativeDef(tree: DefDef) { + tree match { + case DefDef(_, name, _, params :: _, _, _) => + if (settings.lint && !treeInfo.isLeftAssoc(name.decodedName) && params.exists(p => isByName(p.symbol))) + unit.warning(tree.pos, + "by-name parameters will be evaluated eagerly when called as a right-associative infix operator. For more details, see SI-1980.") + case _ => + } + } + /** Check that a deprecated val or def does not override a * concrete, non-deprecated method. If it does, then * deprecation is meaningless. @@ -1600,6 +1610,10 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans if (!sym.isConstructor && !sym.isEffectivelyFinal && !sym.isSynthetic) checkAccessibilityOfReferencedTypes(tree) } + tree match { + case dd: DefDef => checkByNameRightAssociativeDef(dd) + case _ => + } tree case Template(parents, self, body) => |