diff options
Diffstat (limited to 'test/files/run/macro-term-declared-in-class')
-rw-r--r-- | test/files/run/macro-term-declared-in-class/Impls_1.scala | 11 | ||||
-rw-r--r-- | test/files/run/macro-term-declared-in-class/Macros_Test_2.scala | 7 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/macro-term-declared-in-class/Impls_1.scala b/test/files/run/macro-term-declared-in-class/Impls_1.scala new file mode 100644 index 0000000000..c43f5f3f53 --- /dev/null +++ b/test/files/run/macro-term-declared-in-class/Impls_1.scala @@ -0,0 +1,11 @@ +import scala.reflect.macros.blackbox.Context + +object Impls { + def foo(c: Context) = { + import c.{prefix => prefix} + import c.universe._ + val printPrefix = Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("prefix = " + prefix)))) + val body = Block(List(printPrefix), Apply(Select(Ident(definitions.PredefModule), TermName("println")), List(Literal(Constant("it works"))))) + c.Expr[Unit](body) + } +}
\ No newline at end of file diff --git a/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala new file mode 100644 index 0000000000..5898d94dc1 --- /dev/null +++ b/test/files/run/macro-term-declared-in-class/Macros_Test_2.scala @@ -0,0 +1,7 @@ +class Macros { + def foo: Unit = macro Impls.foo +} + +object Test extends App { + new Macros().foo +}
\ No newline at end of file |