diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-19 12:01:25 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-19 20:25:35 +0200 |
commit | 648dae6a504f0a5c24d3a7f6efc996f508a006ce (patch) | |
tree | 8addffd07f20b5c75351352db1291708be887ccf /test/files/run/t6394a | |
parent | b0a4d536482c6582bafb383a30f553862aceb00f (diff) | |
download | scala-648dae6a504f0a5c24d3a7f6efc996f508a006ce.tar.gz scala-648dae6a504f0a5c24d3a7f6efc996f508a006ce.tar.bz2 scala-648dae6a504f0a5c24d3a7f6efc996f508a006ce.zip |
SI-6394 fixes macros.Context.enclosingClass
Previously I used typer.context.enclClass, but it seems to do something
completely unexpected, so I switched to manual context traversal.
Diffstat (limited to 'test/files/run/t6394a')
-rw-r--r-- | test/files/run/t6394a/Macros_1.scala | 12 | ||||
-rw-r--r-- | test/files/run/t6394a/Test_2.scala | 4 |
2 files changed, 16 insertions, 0 deletions
diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala new file mode 100644 index 0000000000..3d39d3e40a --- /dev/null +++ b/test/files/run/t6394a/Macros_1.scala @@ -0,0 +1,12 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c:Context): c.Expr[Any] = { + import c.universe._ + + val selfTree = This(c.enclosingClass.symbol.asModule.moduleClass) + c.Expr[AnyRef](selfTree) + } + + def foo: Any = macro impl +}
\ No newline at end of file diff --git a/test/files/run/t6394a/Test_2.scala b/test/files/run/t6394a/Test_2.scala new file mode 100644 index 0000000000..75e84f0e38 --- /dev/null +++ b/test/files/run/t6394a/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + println(Macros.foo) + override def toString = "TEST" +}
\ No newline at end of file |