summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-12-27 22:28:41 -0800
committerPaul Phillips <paulp@improving.org>2011-12-27 23:34:56 -0800
commit33ab1a574af0d5f736ab73c5a18cc6a4cb36cbb0 (patch)
tree9377b7c1ecc5f81864178e873b46289af2bfb16a
parent99c5d831613bf49afc702dc6aca7ce47b30eab7b (diff)
downloadscala-33ab1a574af0d5f736ab73c5a18cc6a4cb36cbb0.tar.gz
scala-33ab1a574af0d5f736ab73c5a18cc6a4cb36cbb0.tar.bz2
scala-33ab1a574af0d5f736ab73c5a18cc6a4cb36cbb0.zip
Tone down insensible-equality warning.
Closes SI-5175.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rw-r--r--test/files/neg/checksensible.check8
-rw-r--r--test/files/pos/t5175.flags1
-rw-r--r--test/files/pos/t5175.scala9
4 files changed, 12 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 98f1c96cad..f920f3c135 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -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
diff --git a/test/files/neg/checksensible.check b/test/files/neg/checksensible.check
index d45d16165f..0881205bb4 100644
--- a/test/files/neg/checksensible.check
+++ b/test/files/neg/checksensible.check
@@ -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
^
@@ -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
diff --git a/test/files/pos/t5175.flags b/test/files/pos/t5175.flags
new file mode 100644
index 0000000000..e8fb65d50c
--- /dev/null
+++ b/test/files/pos/t5175.flags
@@ -0,0 +1 @@
+-Xfatal-warnings \ No newline at end of file
diff --git a/test/files/pos/t5175.scala b/test/files/pos/t5175.scala
new file mode 100644
index 0000000000..e15cc3affd
--- /dev/null
+++ b/test/files/pos/t5175.scala
@@ -0,0 +1,9 @@
+object Test {
+ def ==(p: Phase): Int = 0
+
+ def foo {
+ ==(new Phase())
+ }
+}
+
+class Phase