Skip to content

Commit

Permalink
Tone down insensible-equality warning.
Browse files Browse the repository at this point in the history
Closes SI-5175.
  • Loading branch information
paulp committed Dec 28, 2011
1 parent 99c5d83 commit 33ab1a5
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
Expand Up @@ -1092,7 +1092,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R
}

// possibleNumericCount is insufficient or this will warn on e.g. Boolean == j.l.Boolean
if (nullCount == 0 && !(isSpecial(receiver) && isSpecial(actual))) {
if (isWarnable && nullCount == 0 && !(isSpecial(receiver) && isSpecial(actual))) {
if (actual isSubClass receiver) ()
else if (receiver isSubClass actual) ()
// warn only if they have no common supertype below Object
Expand Down
8 changes: 1 addition & 7 deletions test/files/neg/checksensible.check
Expand Up @@ -28,12 +28,6 @@ checksensible.scala:27: error: comparing values of types Int and Unit using `=='
checksensible.scala:29: error: comparing values of types Int and String using `==' will always yield false
1 == "abc"
^
checksensible.scala:32: error: String and Int are unrelated: they will most likely never compare equal
"abc" == 1 // warns because the lub of String and Int is Any
^
checksensible.scala:33: error: Some[Int] and Int are unrelated: they will most likely never compare equal
Some(1) == 1 // as above
^
checksensible.scala:38: error: comparing a fresh object using `==' will always yield false
new AnyRef == 1
^
Expand Down Expand Up @@ -100,4 +94,4 @@ checksensible.scala:84: error: comparing values of types EqEqRefTest.this.C3 and
checksensible.scala:95: error: comparing values of types Unit and Int using `!=' will always yield true
while ((c = in.read) != -1)
^
34 errors found
32 errors found
1 change: 1 addition & 0 deletions test/files/pos/t5175.flags
@@ -0,0 +1 @@
-Xfatal-warnings
9 changes: 9 additions & 0 deletions test/files/pos/t5175.scala
@@ -0,0 +1,9 @@
object Test {
def ==(p: Phase): Int = 0

def foo {
==(new Phase())
}
}

class Phase

0 comments on commit 33ab1a5

Please sign in to comment.