diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2013-06-05 16:51:06 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2013-06-07 22:26:56 +0200 |
commit | ee646e9c84290e721c4ee9fe6247d4b95840e871 (patch) | |
tree | 9e95db43b84677f0f874d9e0f6c584ad2c49259c /test/files/neg | |
parent | 488444b327f222fa4ef317b5d96fb7cdf732d4d2 (diff) | |
download | scala-ee646e9c84290e721c4ee9fe6247d4b95840e871.tar.gz scala-ee646e9c84290e721c4ee9fe6247d4b95840e871.tar.bz2 scala-ee646e9c84290e721c4ee9fe6247d4b95840e871.zip |
fixes a crash on a degenerate macro definition
Previous version of the MacroImplReference extractor didn't take into
the account the fact that RefTree.qualifier.symbol can be null (and it can
be null if RefTree is an Ident, because then qualifier is an EmptyTree).
This led to NPEs for really weird macro defs that refer to local methods
as their corresponding macro impls. Now I check for this corner case,
and the stuff now longer crashes.
This was wrong; this is how I fixed it; the world is now a better place.
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/macro-invalidshape.check | 7 | ||||
-rw-r--r-- | test/files/neg/macro-invalidshape/Macros_Test_2.scala | 5 |
2 files changed, 11 insertions, 1 deletions
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 { |