diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-12-30 18:34:23 -0800 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-12-30 18:34:23 -0800 |
commit | 71082268f0f61be837828533830f37ef7f1f6117 (patch) | |
tree | 030c693028cc4f0ab155b2cc47d1d052d780fb45 /test | |
parent | 2b3c6606a637746c14785f4de0829d9a9598e899 (diff) | |
parent | 2375e2d878e6c493d9ab3097ef1d13d8641a6209 (diff) | |
download | scala-71082268f0f61be837828533830f37ef7f1f6117.tar.gz scala-71082268f0f61be837828533830f37ef7f1f6117.tar.bz2 scala-71082268f0f61be837828533830f37ef7f1f6117.zip |
Merge pull request #1816 from scalamacros/topic/enclosures
enclosures are now strongly typed and are no longer vals
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/macro-enclosures.check | 32 | ||||
-rw-r--r-- | test/files/run/macro-enclosures.flags | 1 | ||||
-rw-r--r-- | test/files/run/macro-enclosures/Impls_Macros_1.scala | 14 | ||||
-rw-r--r-- | test/files/run/macro-enclosures/Test_2.scala | 11 | ||||
-rw-r--r-- | test/files/run/t6394a/Macros_1.scala | 2 |
5 files changed, 59 insertions, 1 deletions
diff --git a/test/files/run/macro-enclosures.check b/test/files/run/macro-enclosures.check new file mode 100644 index 0000000000..36bb67e194 --- /dev/null +++ b/test/files/run/macro-enclosures.check @@ -0,0 +1,32 @@ +enclosingPackage = package test { + object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo + } +} +enclosingClass = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingImpl = object Test extends scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingTemplate = scala.AnyRef { + def <init>() = { + super.<init>(); + () + }; + def test = Macros.foo +} +enclosingMethod = def test = Macros.foo +enclosingDef = def test = Macros.foo diff --git a/test/files/run/macro-enclosures.flags b/test/files/run/macro-enclosures.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/files/run/macro-enclosures.flags @@ -0,0 +1 @@ +-language:experimental.macros
\ No newline at end of file diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala new file mode 100644 index 0000000000..cd54028676 --- /dev/null +++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala @@ -0,0 +1,14 @@ +import scala.reflect.macros.Context + +object Macros { + def impl(c: Context) = c.universe.reify { + println("enclosingPackage = " + c.literal(c.enclosingPackage.toString).splice) + println("enclosingClass = " + c.literal(c.enclosingClass.toString).splice) + println("enclosingImpl = " + c.literal(c.enclosingImpl.toString).splice) + println("enclosingTemplate = " + c.literal(c.enclosingTemplate.toString).splice) + println("enclosingMethod = " + c.literal(c.enclosingMethod.toString).splice) + println("enclosingDef = " + c.literal(c.enclosingDef.toString).splice) + } + + def foo = macro impl +}
\ No newline at end of file diff --git a/test/files/run/macro-enclosures/Test_2.scala b/test/files/run/macro-enclosures/Test_2.scala new file mode 100644 index 0000000000..779fe5211e --- /dev/null +++ b/test/files/run/macro-enclosures/Test_2.scala @@ -0,0 +1,11 @@ +object Test extends App { + test.Test.test +} + +package test { + object Test { + def test = { + Macros.foo + } + } +}
\ No newline at end of file diff --git a/test/files/run/t6394a/Macros_1.scala b/test/files/run/t6394a/Macros_1.scala index 3d39d3e40a..5aa07e7f41 100644 --- a/test/files/run/t6394a/Macros_1.scala +++ b/test/files/run/t6394a/Macros_1.scala @@ -4,7 +4,7 @@ object Macros { def impl(c:Context): c.Expr[Any] = { import c.universe._ - val selfTree = This(c.enclosingClass.symbol.asModule.moduleClass) + val selfTree = This(c.enclosingImpl.symbol.asModule.moduleClass) c.Expr[AnyRef](selfTree) } |