summaryrefslogtreecommitdiff
path: root/test/files/neg/t8219-any-any-ref-equals.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-02-04 15:55:59 +0100
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-02-10 10:58:58 -0800
commit4a8edc03653cb0f6b6ed1cdea1779a19df20f8f5 (patch)
treea2504af682ddcd74d8050bbf26639b5c58b7c636 /test/files/neg/t8219-any-any-ref-equals.scala
parentb0f81ed35a45fffb9d0761299013d9d5f324ade6 (diff)
downloadscala-4a8edc03653cb0f6b6ed1cdea1779a19df20f8f5.tar.gz
scala-4a8edc03653cb0f6b6ed1cdea1779a19df20f8f5.tar.bz2
scala-4a8edc03653cb0f6b6ed1cdea1779a19df20f8f5.zip
SI-8129 Make Object#== override Any#==
And the same for != If we tried to declare these signatures in non-fictional classes, we would be chastised about collapsing into the "same signature after erasure". This will have an influence of typing, as the typechecking of arguments is sensitive to overloading: if multiple variants are feasible, the argument will be typechecked with a wildcard expected type. So people inspecting the types of the arguments to `==` before this change might have seen an interesting type for `if (true) x else y`, but now the `If` will have type `Any`, as we don't need to calculate the LUB. I've left a TODO to note that we should really make `Any#{==, !=}` non-final and include a final override in `AnyVal`. But I don't think that is particularly urgent.
Diffstat (limited to 'test/files/neg/t8219-any-any-ref-equals.scala')
-rw-r--r--test/files/neg/t8219-any-any-ref-equals.scala8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/files/neg/t8219-any-any-ref-equals.scala b/test/files/neg/t8219-any-any-ref-equals.scala
new file mode 100644
index 0000000000..f1b81fa734
--- /dev/null
+++ b/test/files/neg/t8219-any-any-ref-equals.scala
@@ -0,0 +1,8 @@
+object Test {
+ // The error message tells us that AnyRef#== and Any#== are overloaded.
+ // A real class couldn't define such an overload, why do we allow AnyRef
+ // to do so?
+ "".==[Int]
+ ("": AnyRef).==[Int]
+ ("": Object).==[Int]
+}