diff options
author | Seth Tisue <seth@tisue.net> | 2015-09-08 13:23:22 -0400 |
---|---|---|
committer | Seth Tisue <seth@tisue.net> | 2015-09-08 13:23:22 -0400 |
commit | ad17b552b8f7c3a435ad8de71cd7268f905a1b8d (patch) | |
tree | fc4093f85c79cb9dc6bfb77a62128652f32a68ec /test/files/run/toolbox_expand_macro.scala | |
parent | 468abc47999a39801f9e8672900fea797dea6611 (diff) | |
download | scala-ad17b552b8f7c3a435ad8de71cd7268f905a1b8d.tar.gz scala-ad17b552b8f7c3a435ad8de71cd7268f905a1b8d.tar.bz2 scala-ad17b552b8f7c3a435ad8de71cd7268f905a1b8d.zip |
Merge remote-tracking branch 'origin/2.11.x' into 2.12.x
only trivial merge conflicts here.
not dealing with PR #4333 in this merge because there is a substantial
conflict there -- so that's why I stopped at
63daba33ae99471175e9d7b20792324615f5999b for now
Diffstat (limited to 'test/files/run/toolbox_expand_macro.scala')
-rw-r--r-- | test/files/run/toolbox_expand_macro.scala | 23 |
1 files changed, 23 insertions, 0 deletions
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)")) +} |