summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2012-01-04 07:05:19 +0100
committerMartin Odersky <odersky@gmail.com>2012-01-04 07:05:19 +0100
commitfafbffc2950aa3f25f91575786093e044f9af549 (patch)
treea3ebfdd4cc67b4e4b7f4299cdc872e5b1210599a /test
parent471a63a9e6618f25feb3a5266c38ad98ea2a5ac7 (diff)
downloadscala-fafbffc2950aa3f25f91575786093e044f9af549.tar.gz
scala-fafbffc2950aa3f25f91575786093e044f9af549.tar.bz2
scala-fafbffc2950aa3f25f91575786093e044f9af549.zip
Closes SI-5354.
The reason why the test case compiled without error is pretty devious: When checking the `Foo.x' implicit, a CyclicReference error occurs which causes the alternative to be discarded. Why a CylicReference? Because the inferencer tries to decide whether the owner of `z` is a subclass of the owner od `x`. To do this, it computed the info of the owner of `z1`, which is not complete because no result type for `f1` was given. Hence a CyclicReference error. The fix is twofold: (1) We make isNonBottomSubClass smarter so that it always returns false if the symbol in question is not a type; hence the info need not be computed. (2) It's dubious to swallow CyclicReference errors anywhere, but I deemed it too risky to propagate them. But at least the CyclicReference is now logged if -Ylog-implicit is true. This hopefully spares future maintainers the same detective work I had to go through when digging this out.
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t5354.check7
-rw-r--r--test/files/neg/t5354.scala15
2 files changed, 22 insertions, 0 deletions
diff --git a/test/files/neg/t5354.check b/test/files/neg/t5354.check
new file mode 100644
index 0000000000..e47cecb5fe
--- /dev/null
+++ b/test/files/neg/t5354.check
@@ -0,0 +1,7 @@
+t5354.scala:9: error: ambiguous implicit values:
+ both method x123 in package foo of type => foo.Bippy
+ and method z of type => foo.Bippy
+ match expected type foo.Bippy
+ implicitly[Bippy]
+ ^
+one error found
diff --git a/test/files/neg/t5354.scala b/test/files/neg/t5354.scala
new file mode 100644
index 0000000000..99b5650155
--- /dev/null
+++ b/test/files/neg/t5354.scala
@@ -0,0 +1,15 @@
+package object foo {
+ implicit def x123: Bippy = new Bippy("x")
+}
+package foo {
+ class Bippy(override val toString: String){ }
+ class Dingus {
+ def f1 = {
+ implicit def z: Bippy = new Bippy("z")
+ implicitly[Bippy]
+ }
+ }
+ object Test extends App {
+ println(new Dingus().f1)
+ }
+}