summaryrefslogtreecommitdiff
path: root/test/files/run/t6814
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/run/t6814')
-rw-r--r--test/files/run/t6814/Macros_1.scala24
-rw-r--r--test/files/run/t6814/Test_2.scala3
2 files changed, 27 insertions, 0 deletions
diff --git a/test/files/run/t6814/Macros_1.scala b/test/files/run/t6814/Macros_1.scala
new file mode 100644
index 0000000000..0257f451d6
--- /dev/null
+++ b/test/files/run/t6814/Macros_1.scala
@@ -0,0 +1,24 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl(c: Context) = {
+ import c.universe._
+
+ def test(tree: Tree, mode: c.TypecheckMode): String = {
+ try c.typecheck(tree, mode, silent = false).tpe.toString
+ catch { case c.TypecheckException(_, msg) => msg }
+ }
+
+ q"""
+ println(${test(q"List(1, 2)", c.TERMmode)})
+ println(${test(q"List", c.TERMmode)})
+ println(${test(q"RuntimeException", c.TERMmode)})
+ println(${test(tq"List[Int]", c.TYPEmode)})
+ println(${test(tq"List", c.TYPEmode)})
+ println(${test(q"List", c.TYPEmode)})
+ println(${test(q"List(1, 2)", c.TYPEmode)})
+ """
+ }
+ def foo: Unit = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/t6814/Test_2.scala b/test/files/run/t6814/Test_2.scala
new file mode 100644
index 0000000000..acfddae942
--- /dev/null
+++ b/test/files/run/t6814/Test_2.scala
@@ -0,0 +1,3 @@
+object Test extends App {
+ Macros.foo
+} \ No newline at end of file