summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-04-10 06:30:08 -0700
committerPaul Phillips <paulp@improving.org>2012-04-10 06:42:45 -0700
commit00e9446bfca132bf6ec89b9d75a2b90ad5ea098d (patch)
tree12cae02ad348ce037cd25feeb95c372856356062 /src
parentbed400c5a8d4fc5f5ee4b270f757cdfae94c3f6a (diff)
downloadscala-00e9446bfca132bf6ec89b9d75a2b90ad5ea098d.tar.gz
scala-00e9446bfca132bf6ec89b9d75a2b90ad5ea098d.tar.bz2
scala-00e9446bfca132bf6ec89b9d75a2b90ad5ea098d.zip
Fix for SI-5648.
More care in warning about bad comparisons.
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 68a722aab4..806ee480f0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1053,10 +1053,17 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
/** Symbols which limit the warnings we can issue since they may be value types */
val isMaybeValue = Set(AnyClass, AnyRefClass, AnyValClass, ObjectClass, ComparableClass, JavaSerializableClass)
- // Whether def equals(other: Any) is overridden or synthetic
+ // Whether def equals(other: Any) has known behavior: it is the default
+ // inherited from java.lang.Object, or it is a synthetically generated
+ // case equals. TODO - more cases are warnable if the target is a synthetic
+ // equals.
def isUsingWarnableEquals = {
val m = receiver.info.member(nme.equals_)
- (m == Object_equals) || (m == Any_equals) || (m.isSynthetic && m.owner.isCase)
+ def n = actual.info.member(nme.equals_)
+ ( (m == Object_equals)
+ || (m == Any_equals)
+ || (m.isSynthetic && m.owner.isCase && !n.owner.isCase)
+ )
}
// Whether this == or != is one of those defined in Any/AnyRef or an overload from elsewhere.
def isUsingDefaultScalaOp = {