summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJan Bessai <Jan.Bessai@tu-dortmund.de>2015-08-23 12:11:58 +0200
committerJan Bessai <Jan.Bessai@tu-dortmund.de>2015-08-23 12:11:58 +0200
commit43d3eec9fd3656b8ed0746a25c0a1ce0e9e74353 (patch)
treee71930b3c5095c904c9f35119c0f1d6097bbd56e /test
parentee291bdce9be7d5bfcb779156b40e80c5653d099 (diff)
downloadscala-43d3eec9fd3656b8ed0746a25c0a1ce0e9e74353.tar.gz
scala-43d3eec9fd3656b8ed0746a25c0a1ce0e9e74353.tar.bz2
scala-43d3eec9fd3656b8ed0746a25c0a1ce0e9e74353.zip
SI-6636 Fix macro expansion in toolboxes
Diffstat (limited to 'test')
-rw-r--r--test/files/run/toolbox_expand_macro.check1
-rw-r--r--test/files/run/toolbox_expand_macro.scala23
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)"))
+}