diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-05-11 12:14:19 -0700 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-05-11 12:14:19 -0700 |
commit | aa7568e8161552952ae16e0a5a79ce3ea517abe3 (patch) | |
tree | 679819f1381ec39b79169c2c21ca5d6acca72b63 /test/files/neg/t7166/Impls_Macros_1.scala | |
parent | 0ae7e55209129dc3d76d56887e88b2c817e6b904 (diff) | |
parent | 4e64a2731d6e4c27e2fd4c75559e118708e79ad5 (diff) | |
download | scala-aa7568e8161552952ae16e0a5a79ce3ea517abe3.tar.gz scala-aa7568e8161552952ae16e0a5a79ce3ea517abe3.tar.bz2 scala-aa7568e8161552952ae16e0a5a79ce3ea517abe3.zip |
Merge pull request #2494 from scalamacros/ticket/5923
makes sense of implicit macros!
Diffstat (limited to 'test/files/neg/t7166/Impls_Macros_1.scala')
-rw-r--r-- | test/files/neg/t7166/Impls_Macros_1.scala | 26 |
1 files changed, 26 insertions, 0 deletions
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] +} |