summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@typesafe.com>2014-11-10 12:48:04 +0100
committerLukas Rytz <lukas.rytz@typesafe.com>2014-11-10 12:48:04 +0100
commit60d59ee9f3ac37b59c93488f5e71fe38c5fff4b7 (patch)
tree82c2e59eded49109923d095b799bb836b2bdc869
parent5a7875fd0e6af19286f3ff125d4ad9b311a7ad7e (diff)
parentb8f7fbee940856173dd19afddcd689495313c4cf (diff)
downloadscala-60d59ee9f3ac37b59c93488f5e71fe38c5fff4b7.tar.gz
scala-60d59ee9f3ac37b59c93488f5e71fe38c5fff4b7.tar.bz2
scala-60d59ee9f3ac37b59c93488f5e71fe38c5fff4b7.zip
Merge pull request #4102 from retronym/ticket/8965
SI-8965 Account for corner case in "unrelated types" warning
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rw-r--r--test/files/pos/t8965.flags1
-rw-r--r--test/files/pos/t8965.scala7
3 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index 59d1a6da85..d2931ff9e1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1095,7 +1095,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
// better to have lubbed and lost
def warnIfLubless(): Unit = {
val common = global.lub(List(actual.tpe, receiver.tpe))
- if (ObjectTpe <:< common)
+ if (ObjectTpe <:< common && !(ObjectTpe <:< actual.tpe && ObjectTpe <:< receiver.tpe))
unrelatedTypes()
}
// warn if actual has a case parent that is not same as receiver's;
diff --git a/test/files/pos/t8965.flags b/test/files/pos/t8965.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/pos/t8965.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/pos/t8965.scala b/test/files/pos/t8965.scala
new file mode 100644
index 0000000000..4f39330f4e
--- /dev/null
+++ b/test/files/pos/t8965.scala
@@ -0,0 +1,7 @@
+class A {
+ def f(x: Any with AnyRef, y: Any with AnyRef) = x eq y
+ // a.scala:2: warning: Any and Any are unrelated: they will most likely never compare equal
+ // def f(x: Any with AnyRef, y: Any with AnyRef) = x eq y
+ // ^
+ // one warning found
+}