diff options
Diffstat (limited to 'test/files')
-rw-r--r-- | test/files/neg/t7166.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7166/Impls_Macros_1.scala | 26 | ||||
-rw-r--r-- | test/files/neg/t7166/Test_2.scala | 3 |
3 files changed, 33 insertions, 0 deletions
diff --git a/test/files/neg/t7166.check b/test/files/neg/t7166.check new file mode 100644 index 0000000000..c87198cb27 --- /dev/null +++ b/test/files/neg/t7166.check @@ -0,0 +1,4 @@ +Test_2.scala:2: error: silent = true does work! + println(implicitly[Complex[Foo]]) + ^ +one error found diff --git a/test/files/neg/t7166/Impls_Macros_1.scala b/test/files/neg/t7166/Impls_Macros_1.scala new file mode 100644 index 0000000000..62a15657c3 --- /dev/null +++ b/test/files/neg/t7166/Impls_Macros_1.scala @@ -0,0 +1,26 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +trait Complex[T] + +class Foo + +object Complex { + def impl[T: c.WeakTypeTag](c: Context): c.Expr[Complex[T]] = { + import c.universe._ + def shout(msg: String) = { + val cannotShutMeUp = c.asInstanceOf[scala.reflect.macros.runtime.Context].universe.currentRun.currentUnit.error _ + cannotShutMeUp(c.enclosingPosition.asInstanceOf[scala.reflect.internal.util.Position], msg) + } + try { + val complexOfT = appliedType(typeOf[Complex[_]], List(weakTypeOf[T])) + val infiniteRecursion = c.inferImplicitValue(complexOfT, silent = true) + shout("silent = true does work!") + } catch { + case ex: Exception => shout(ex.toString) + } + c.literalNull + } + + implicit def genComplex[T]: Complex[T] = macro impl[T] +} diff --git a/test/files/neg/t7166/Test_2.scala b/test/files/neg/t7166/Test_2.scala new file mode 100644 index 0000000000..dcc4593335 --- /dev/null +++ b/test/files/neg/t7166/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + println(implicitly[Complex[Foo]]) +}
\ No newline at end of file |