summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala7
-rw-r--r--test/files/neg/macro-invalidshape.check7
-rw-r--r--test/files/neg/macro-invalidshape/Macros_Test_2.scala5
3 files changed, 15 insertions, 4 deletions
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index d1e8a04553..3a8d3fd460 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -837,11 +837,12 @@ abstract class TreeInfo {
def unapply(tree: Tree) = refPart(tree) match {
case ref: RefTree => {
- val isBundle = definitions.isMacroBundleType(ref.qualifier.tpe)
+ val qual = ref.qualifier
+ val isBundle = definitions.isMacroBundleType(qual.tpe)
val owner =
- if (isBundle) ref.qualifier.tpe.typeSymbol
+ if (isBundle) qual.tpe.typeSymbol
else {
- val sym = ref.qualifier.symbol
+ val sym = if (qual.hasSymbolField) qual.symbol else NoSymbol
if (sym.isModule) sym.moduleClass else sym
}
Some((isBundle, owner, ref.symbol, dissectApplied(tree).targs))
diff --git a/test/files/neg/macro-invalidshape.check b/test/files/neg/macro-invalidshape.check
index 40a2952569..1938f5ae47 100644
--- a/test/files/neg/macro-invalidshape.check
+++ b/test/files/neg/macro-invalidshape.check
@@ -12,4 +12,9 @@ Macros_Test_2.scala:4: error: missing arguments for method foo in object Impls;
follow this method with `_' if you want to treat it as a partially applied function
def foo3(x: Any) = macro {2; Impls.foo}
^
-three errors found
+Macros_Test_2.scala:7: error: macro implementation reference has wrong shape. required:
+macro [<static object>].<method name>[[<type args>]] or
+macro [<macro bundle>].<method name>[[<type args>]]
+ def foo = macro impl
+ ^
+four errors found
diff --git a/test/files/neg/macro-invalidshape/Macros_Test_2.scala b/test/files/neg/macro-invalidshape/Macros_Test_2.scala
index f39ad20c5d..cf37e14d8e 100644
--- a/test/files/neg/macro-invalidshape/Macros_Test_2.scala
+++ b/test/files/neg/macro-invalidshape/Macros_Test_2.scala
@@ -2,6 +2,11 @@ object Macros {
def foo1(x: Any) = macro 2
def foo2(x: Any) = macro Impls.foo(null)(null)
def foo3(x: Any) = macro {2; Impls.foo}
+ {
+ def impl(c: scala.reflect.macros.Context) = c.literalUnit
+ def foo = macro impl
+ foo
+ }
}
object Test extends App {