From 70f001181734f76064d97ec25b1afd6aad49b684 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 14 Jan 2013 23:55:25 +0100 Subject: refactors macro tests putting in a nutshell, this patch: * condenses some macro-XXX-a/b/c/... bundles * renames some tests to prepare for other macro flavors * introduces some additional tests --- .../Impls_Macros_1.scala | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala (limited to 'test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala') diff --git a/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala new file mode 100644 index 0000000000..4c009cc367 --- /dev/null +++ b/test/files/run/macro-term-declared-in-implicit-class/Impls_Macros_1.scala @@ -0,0 +1,19 @@ +import scala.reflect.macros.{Context => Ctx} + +object Impls { + def toOptionOfInt(c: Ctx) = { + 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(Ident(definitions.SomeModule), List(Select(Select(prefix.tree, TermName("x")), TermName("toInt"))))) + c.Expr[Option[Int]](body) + } +} + +object Macros { + implicit def foo(x: String): Foo = new Foo(x) + + class Foo(val x: String) { + def toOptionOfInt = macro Impls.toOptionOfInt + } +} \ No newline at end of file -- cgit v1.2.3