From b242637ee1fc6db79992a67073219ec87150d06a Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Wed, 25 Apr 2012 21:13:29 +0300 Subject: diagnostics for SI-5692 --- src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala | 13 ++++++++++--- test/pending/run/t5692.flags | 1 + test/pending/run/t5692/Impls_Macros_1.scala | 9 +++++++++ test/pending/run/t5692/Test_2.scala | 4 ++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 test/pending/run/t5692.flags create mode 100644 test/pending/run/t5692/Impls_Macros_1.scala create mode 100644 test/pending/run/t5692/Test_2.scala diff --git a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala index 52648380ec..192cc94b90 100644 --- a/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala +++ b/src/compiler/scala/tools/nsc/symtab/classfile/Pickler.scala @@ -62,9 +62,16 @@ abstract class Pickler extends SubComponent { // when we pickle it: so let's report an error instead. We know next // to nothing about what happened, but our supposition is a lot better // than "bad type: " in terms of explanatory power. - for (t <- unit.body ; if t.isErroneous) { - unit.error(t.pos, "erroneous or inaccessible type") - return + for (t <- unit.body) { + if (t.isErroneous) { + unit.error(t.pos, "erroneous or inaccessible type") + return + } + + if (!t.isDef && t.hasSymbol && t.symbol.isTermMacro) { + unit.error(t.pos, "macro has not been expanded") + return + } } pickle(unit.body) diff --git a/test/pending/run/t5692.flags b/test/pending/run/t5692.flags new file mode 100644 index 0000000000..cd66464f2f --- /dev/null +++ b/test/pending/run/t5692.flags @@ -0,0 +1 @@ +-language:experimental.macros \ No newline at end of file diff --git a/test/pending/run/t5692/Impls_Macros_1.scala b/test/pending/run/t5692/Impls_Macros_1.scala new file mode 100644 index 0000000000..f9c1e5f12b --- /dev/null +++ b/test/pending/run/t5692/Impls_Macros_1.scala @@ -0,0 +1,9 @@ +import scala.reflect.makro.Context + +object Impls { + def impl[A](c: reflect.makro.Context) = c.reify(()) +} + +object Macros { + def decl[A] = macro Impls.impl[A] +} \ No newline at end of file diff --git a/test/pending/run/t5692/Test_2.scala b/test/pending/run/t5692/Test_2.scala new file mode 100644 index 0000000000..29251a5ef5 --- /dev/null +++ b/test/pending/run/t5692/Test_2.scala @@ -0,0 +1,4 @@ +object Test extends App { + val x = Macros.decl + def y() { Macros.decl(); } +} \ No newline at end of file -- cgit v1.2.3