diff options
Diffstat (limited to 'test')
4 files changed, 25 insertions, 0 deletions
diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams.check b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check new file mode 100644 index 0000000000..73f57b0b81 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams.check @@ -0,0 +1,3 @@ +reflective compilation has failed:
+
+macros cannot be partially applied
diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams.flags b/test/files/run/macro-invalidusage-partialapplication-with-tparams.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala new file mode 100644 index 0000000000..67a19a6d62 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Impls_Macros_1.scala @@ -0,0 +1,13 @@ +import scala.reflect.makro.{Context => Ctx} + +object Impls { + def foo[T: c.TypeTag](c: Ctx)(x: c.Expr[T]) = { + import c.universe._ + val body = Apply(Select(Ident(definitions.PredefModule), newTermName("println")), List(Literal(Constant(x.tree.toString)))) + c.Expr[Unit](body) + } +} + +object Macros { + def foo[T](x: T) = macro Impls.foo[T] +}
\ No newline at end of file diff --git a/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala new file mode 100644 index 0000000000..f51cc7e699 --- /dev/null +++ b/test/files/run/macro-invalidusage-partialapplication-with-tparams/Test_2.scala @@ -0,0 +1,8 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + import scala.reflect.runtime.{currentMirror => cm} + import scala.tools.reflect.ToolBox + val tree = Select(Ident("Macros"), newTermName("foo")) + try cm.mkToolBox().runExpr(tree) + catch { case ex: Throwable => println(ex.getMessage) } +} |