aboutsummaryrefslogtreecommitdiff
path: root/tests/disabled/macro/run/t7777
diff options
context:
space:
mode:
Diffstat (limited to 'tests/disabled/macro/run/t7777')
-rw-r--r--tests/disabled/macro/run/t7777/Macros_1.scala17
-rw-r--r--tests/disabled/macro/run/t7777/Test_2.scala6
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/disabled/macro/run/t7777/Macros_1.scala b/tests/disabled/macro/run/t7777/Macros_1.scala
new file mode 100644
index 000000000..1dc6d6740
--- /dev/null
+++ b/tests/disabled/macro/run/t7777/Macros_1.scala
@@ -0,0 +1,17 @@
+import scala.language.experimental.macros
+import scala.language.dynamics
+import scala.reflect.macros.whitebox.Context
+
+class DynMacro extends Dynamic {
+ def applyDynamic(s: String)(xs: Any*): DynMacro =
+ macro DynMacro.applyDynamicMacro
+}
+
+object DynMacro extends DynMacro {
+ def applyDynamicMacro(c: Context)(s: c.Expr[String])(xs: c.Expr[Any]*): c.Expr[DynMacro] = {
+ import c.universe._
+ val Literal(Constant(n: String)) = s.tree
+ val args = xs.map(_.tree.toString).mkString("(", ", ", ")")
+ c.Expr(q"println(${ n + args }); ${c.prefix.tree}")
+ }
+} \ No newline at end of file
diff --git a/tests/disabled/macro/run/t7777/Test_2.scala b/tests/disabled/macro/run/t7777/Test_2.scala
new file mode 100644
index 000000000..7f84f64e4
--- /dev/null
+++ b/tests/disabled/macro/run/t7777/Test_2.scala
@@ -0,0 +1,6 @@
+object Test extends dotty.runtime.LegacyApp {
+ DynMacro.foo(1, 2) // prints "foo(1, 2)"
+ DynMacro.foo(3).bar(4, 5) // prints "bar(4, 5)", then "foo(3)"
+ DynMacro(6).bar(7) // prints "bar(7)", then "apply(6)"
+ DynMacro.foo(8)(9) // Fails!
+} \ No newline at end of file