From 9772ec8b2f15fd8c2971413d90006beb8bf0d2b7 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Thu, 29 Aug 2013 08:29:26 +0200 Subject: typedAnnotated no longer emits nulls Adds a null-check in original synthesis for the result of typedAnnotated. Previously it was possible for the aforementioned result to look like TypeTree() setOriginal Annotated(..., null). Not anymore. --- test/files/run/typed-annotated.check | 1 + test/files/run/typed-annotated/Macros_1.scala | 17 +++++++++++++++++ test/files/run/typed-annotated/Test_2.scala | 3 +++ 3 files changed, 21 insertions(+) create mode 100644 test/files/run/typed-annotated.check create mode 100644 test/files/run/typed-annotated/Macros_1.scala create mode 100644 test/files/run/typed-annotated/Test_2.scala (limited to 'test/files') diff --git a/test/files/run/typed-annotated.check b/test/files/run/typed-annotated.check new file mode 100644 index 0000000000..d81cc0710e --- /dev/null +++ b/test/files/run/typed-annotated.check @@ -0,0 +1 @@ +42 diff --git a/test/files/run/typed-annotated/Macros_1.scala b/test/files/run/typed-annotated/Macros_1.scala new file mode 100644 index 0000000000..dd18c63d90 --- /dev/null +++ b/test/files/run/typed-annotated/Macros_1.scala @@ -0,0 +1,17 @@ +import scala.reflect.macros.Context +import language.experimental.macros + +class ann extends scala.annotation.StaticAnnotation + +object Macros { + def impl(c: Context) = { + import c.universe._ + // val tpt = Annotated(Apply(Select(New(Ident(newTypeName("ann"))), nme.CONSTRUCTOR), List()), Ident(newTypeName("Int"))) + val tpt = Annotated(Apply(Select(New(Ident(newTypeName("ann"))), nme.CONSTRUCTOR), List()), TypeTree(weakTypeOf[Int])) + c.Expr[Unit](Block( + List(ValDef(Modifiers(), newTermName("x"), tpt, Literal(Constant(42)))), + Apply(Ident(newTermName("println")), List(Ident(newTermName("x")))))) + } + + def foo = macro impl +} \ No newline at end of file diff --git a/test/files/run/typed-annotated/Test_2.scala b/test/files/run/typed-annotated/Test_2.scala new file mode 100644 index 0000000000..acfddae942 --- /dev/null +++ b/test/files/run/typed-annotated/Test_2.scala @@ -0,0 +1,3 @@ +object Test extends App { + Macros.foo +} \ No newline at end of file -- cgit v1.2.3