diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-08-31 10:59:57 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2015-08-31 10:59:57 -0700 |
commit | 2ca3f8b7a0e526ee255dad60f79b0fb33bad5d39 (patch) | |
tree | aea20ef81f7ada76b04fcb1f31fb86fba9e5359a /test | |
parent | e07778742f3dfedaa7b9ff153e37ca127916a773 (diff) | |
parent | 43d3eec9fd3656b8ed0746a25c0a1ce0e9e74353 (diff) | |
download | scala-2ca3f8b7a0e526ee255dad60f79b0fb33bad5d39.tar.gz scala-2ca3f8b7a0e526ee255dad60f79b0fb33bad5d39.tar.bz2 scala-2ca3f8b7a0e526ee255dad60f79b0fb33bad5d39.zip |
Merge pull request #4692 from JanBessai/Fix-SI-6636
SI-6636 Fix macro expansion in toolboxes
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/toolbox_expand_macro.check | 1 | ||||
-rw-r--r-- | test/files/run/toolbox_expand_macro.scala | 23 |
2 files changed, 24 insertions, 0 deletions
diff --git a/test/files/run/toolbox_expand_macro.check b/test/files/run/toolbox_expand_macro.check new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/files/run/toolbox_expand_macro.check @@ -0,0 +1 @@ +42 diff --git a/test/files/run/toolbox_expand_macro.scala b/test/files/run/toolbox_expand_macro.scala new file mode 100644 index 0000000000..a52e449168 --- /dev/null +++ b/test/files/run/toolbox_expand_macro.scala @@ -0,0 +1,23 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{universe => ru} +import scala.reflect.runtime.{currentMirror => cm} +import scala.tools.reflect.{ToolBox} + +object Test extends App { + val toolBox = cm.mkToolBox() + val x = 21 + val runtimeMacro = + q"""object RuntimeMacro { + import scala.reflect.macros.whitebox.Context + import scala.language.experimental.macros + + def add(y: Int): Int = macro addImpl + def addImpl(c: Context)(y: c.Expr[Int]): c.Expr[Int] = { + import c.universe._ + val x = $x + c.Expr[Int](q"$$x + $$y") + } + }""" + val s = toolBox.define(runtimeMacro) + println(toolBox.eval(q"$s.add(21)")) +} |