diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-02-03 12:09:59 +0100 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2014-02-10 10:58:58 -0800 |
commit | b0f81ed35a45fffb9d0761299013d9d5f324ade6 (patch) | |
tree | c4ea000186473463803cb8c3477e8e513ba78fa9 /test | |
parent | 4b3dbd91d9d81f61809ef47a2a324eabfb122b71 (diff) | |
download | scala-b0f81ed35a45fffb9d0761299013d9d5f324ade6.tar.gz scala-b0f81ed35a45fffb9d0761299013d9d5f324ade6.tar.bz2 scala-b0f81ed35a45fffb9d0761299013d9d5f324ade6.zip |
SI-8219 Pending test to show suspicous overload in == in AnyRef
% scalac-hash v2.11.0-M7 test/pending/neg/t8219-any-any-ref-equals.scala
test/pending/neg/t8219-any-any-ref-equals.scala:5: error: overloaded method value == with alternatives:
(x$1: AnyRef)Boolean <and>
(x$1: Any)Boolean
does not take type parameters
"".==[Int]
^
one error found
Usually for Java-originated methods, we are allow Object and Any
to unify pre-erasure in method signatures. This is handled in
`matchesParams`, and is predicated on whether the method type is
an instance of `JavaMethodType`
For instance, we are allowed to:
scala> class C { override def equals(a: Any) = false }
defined class C
On account of:
scala> typeOf[Object].decl(nme.equals_).info.getClass
res7: Class[_ <: $r.intp.global.Type] = class scala.reflect.internal.Types$JavaMethodType
But:
scala> typeOf[Object].decl(nme.EQ).defString
res8: String = final def ==(x$1: AnyRef): Boolean
scala> typeOf[Object].decl(nme.EQ).info.getClass
res9: Class[_ <: $r.intp.global.Type] = class scala.reflect.internal.Types$MethodType
More special casing is probably needed.
Diffstat (limited to 'test')
-rw-r--r-- | test/pending/neg/t8219-any-any-ref-equals.scala | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/test/pending/neg/t8219-any-any-ref-equals.scala b/test/pending/neg/t8219-any-any-ref-equals.scala new file mode 100644 index 0000000000..26fd81f9b1 --- /dev/null +++ b/test/pending/neg/t8219-any-any-ref-equals.scala @@ -0,0 +1,6 @@ +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] +} |