From e31a4856f1c35b889b775608836f7d6a6a4262d6 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 12 Dec 2016 12:40:51 +0100 Subject: 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. --- tests/neg/implicitDefs.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests/neg') 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 + } } -- cgit v1.2.3