diff options
author | Paul Phillips <paulp@improving.org> | 2013-05-07 13:54:50 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-05-07 13:54:50 -0700 |
commit | 0f74eda2431ca2b9ae3b48ffdd6f7e5502a0843c (patch) | |
tree | b115f35ba10841494332d3d8f235dc915ea11e0f /src | |
parent | 48e80cb8c715cf8cb6dc73a5f894838671e385a4 (diff) | |
parent | 62cdd7ff9033eaa048fbdb72c58e7b9ac18461cd (diff) | |
download | scala-0f74eda2431ca2b9ae3b48ffdd6f7e5502a0843c.tar.gz scala-0f74eda2431ca2b9ae3b48ffdd6f7e5502a0843c.tar.bz2 scala-0f74eda2431ca2b9ae3b48ffdd6f7e5502a0843c.zip |
Merge pull request #2487 from paulp/issue/6091
SI-6091 overeager warning for reference equality
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 4933b8e0cb..94d92af228 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1063,9 +1063,13 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans case _ => } + private def isObjectOrAnyComparisonMethod(sym: Symbol) = sym match { + case Object_eq | Object_ne | Object_== | Object_!= | Any_== | Any_!= => true + case _ => false + } def checkSensible(pos: Position, fn: Tree, args: List[Tree]) = fn match { - case Select(qual, name @ (nme.EQ | nme.NE | nme.eq | nme.ne)) if args.length == 1 => - def isReferenceOp = name == nme.eq || name == nme.ne + case Select(qual, name @ (nme.EQ | nme.NE | nme.eq | nme.ne)) if args.length == 1 && isObjectOrAnyComparisonMethod(fn.symbol) => + def isReferenceOp = fn.symbol == Object_eq || fn.symbol == Object_ne def isNew(tree: Tree) = tree match { case Function(_, _) | Apply(Select(New(_), nme.CONSTRUCTOR), _) => true |