aboutsummaryrefslogtreecommitdiff
path: root/tests/neg
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-12-12 12:40:51 +0100
committerMartin Odersky <odersky@gmail.com>2016-12-12 12:53:40 +0100
commite31a4856f1c35b889b775608836f7d6a6a4262d6 (patch)
treef8600415b3c67440598e261b44ca3fb51a9c3665 /tests/neg
parent4c1bf42414b7f7ed99653fe841b032eb11864f2a (diff)
downloaddotty-e31a4856f1c35b889b775608836f7d6a6a4262d6.tar.gz
dotty-e31a4856f1c35b889b775608836f7d6a6a4262d6.tar.bz2
dotty-e31a4856f1c35b889b775608836f7d6a6a4262d6.zip
Better diagnosis for cyclic references caused by implicit search
Since we now allow to drop the explicit type of a local implicit val it can happen that this causes a cyclic reference, namely when the typechecking of the right-hand side involves an implicit search. It's unpractical and fragile to avoid this. Instead we give now a nice error message explaining the problem and how to fix it in source code.
Diffstat (limited to 'tests/neg')
-rw-r--r--tests/neg/implicitDefs.scala7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/neg/implicitDefs.scala b/tests/neg/implicitDefs.scala
index 1489344c8..3ec9796e8 100644
--- a/tests/neg/implicitDefs.scala
+++ b/tests/neg/implicitDefs.scala
@@ -8,4 +8,11 @@ object implicitDefs {
implicit val x = 2 // error: type of implicit definition needs to be given explicitly
implicit def y(x: Int) = 3 // error: result type of implicit definition needs to be given explicitly
implicit def z(a: x.type): String = "" // error: implicit conversion may not have a parameter of singleton type
+
+ def foo(implicit x: String) = 1
+
+ def bar() = {
+ implicit val x = foo
+ x
+ }
}