Permalink
Browse files

Fix for SI-5648.

More care in warning about bad comparisons.
  • Loading branch information...
1 parent bed400c commit 00e9446bfca132bf6ec89b9d75a2b90ad5ea098d @paulp paulp committed Apr 10, 2012
@@ -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 = {
@@ -0,0 +1,4 @@
+true
+true
+true
+true
@@ -0,0 +1 @@
+-Xfatal-warnings
View
@@ -0,0 +1,10 @@
+case class C(val s: Int*)
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(new C(1, 3, 7) == new C(1, 3, 7))
+ println(new C(1, 3, 7) == C(1, 3, 7))
+ println(C(1, 3, 7) == new C(1, 3, 7))
+ println(C(1, 3, 7) == C(1, 3, 7))
+ }
+}

0 comments on commit 00e9446

Please sign in to comment.