summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/run/macro-enclosures.check2
-rw-r--r--test/files/run/macro-enclosures/Impls_Macros_1.scala22
2 files changed, 16 insertions, 8 deletions
diff --git a/test/files/run/macro-enclosures.check b/test/files/run/macro-enclosures.check
index 36bb67e194..b6fe7a4a91 100644
--- a/test/files/run/macro-enclosures.check
+++ b/test/files/run/macro-enclosures.check
@@ -30,3 +30,5 @@ enclosingTemplate = scala.AnyRef {
}
enclosingMethod = def test = Macros.foo
enclosingDef = def test = Macros.foo
+enclosingOwner = method test
+enclosingOwnerChain = List(method test, object Test, package test, package <root>)
diff --git a/test/files/run/macro-enclosures/Impls_Macros_1.scala b/test/files/run/macro-enclosures/Impls_Macros_1.scala
index 5b04cf29e9..a0f66a6b98 100644
--- a/test/files/run/macro-enclosures/Impls_Macros_1.scala
+++ b/test/files/run/macro-enclosures/Impls_Macros_1.scala
@@ -3,15 +3,21 @@ import scala.reflect.macros.blackbox.Context
object Macros {
def impl(c: Context) = {
import c.universe._
- reify {
- println("enclosingPackage = " + c.Expr[String](Literal(Constant(c.enclosingPackage.toString))).splice)
- println("enclosingClass = " + c.Expr[String](Literal(Constant(c.enclosingClass.toString))).splice)
- println("enclosingImpl = " + c.Expr[String](Literal(Constant(c.enclosingImpl.toString))).splice)
- println("enclosingTemplate = " + c.Expr[String](Literal(Constant(c.enclosingTemplate.toString))).splice)
- println("enclosingMethod = " + c.Expr[String](Literal(Constant(c.enclosingMethod.toString))).splice)
- println("enclosingDef = " + c.Expr[String](Literal(Constant(c.enclosingDef.toString))).splice)
+ def chain(sym: Symbol): List[Symbol] = sym.owner match {
+ case NoSymbol => sym :: Nil
+ case owner => sym :: chain(owner)
}
+ q"""
+ println("enclosingPackage = " + ${c.enclosingPackage.toString})
+ println("enclosingClass = " + ${c.enclosingClass.toString})
+ println("enclosingImpl = " + ${c.enclosingImpl.toString})
+ println("enclosingTemplate = " + ${c.enclosingTemplate.toString})
+ println("enclosingMethod = " + ${c.enclosingMethod.toString})
+ println("enclosingDef = " + ${c.enclosingDef.toString})
+ println("enclosingOwner = " + ${c.enclosingOwner.toString})
+ println("enclosingOwnerChain = " + ${chain(c.enclosingOwner).toString})
+ """
}
- def foo = macro impl
+ def foo: Any = macro impl
} \ No newline at end of file