Permalink
Browse files

Fix SI-5544

Type-check annotations in a context with a localDummy owner
  • Loading branch information...
lrytz committed May 18, 2012
1 parent ef77088 commit 9c6a7ad81bdb632d3da144d58210b5903b86a3e4
@@ -3246,7 +3246,9 @@ trait Typers extends Modes with Adaptations with Taggings {
reportAnnotationError(NestedAnnotationError(ann, annType))
} else {
val typedAnn = if (selfsym == NoSymbol) {
- typed(ann, mode, annClass.tpe)
+ // local dummy fixes SI-5544
+ val localTyper = newTyper(context.make(ann, context.owner.newLocalDummy(ann.pos)))
+ localTyper.typed(ann, mode, annClass.tpe)
} else {
// Since a selfsym is supplied, the annotation should have
// an extra "self" identifier in scope for type checking.
@@ -0,0 +1,4 @@
+Test_2.scala:2: error: value baz is not a member of object Api
+ Api.baz
+ ^
+one error found
@@ -0,0 +1,8 @@
+import scala.annotation.StaticAnnotation
+
+class ann(val bar: Any) extends StaticAnnotation
+
+object Api {
+ @ann({def baz = "baz!!"})
+ def foo = println("foo")
+}
@@ -0,0 +1,3 @@
+object Test extends App {
+ Api.baz
+}
@@ -0,0 +1 @@
+foo
@@ -0,0 +1,8 @@
+import scala.annotation.StaticAnnotation
+
+class ann(val bar: Any) extends StaticAnnotation
+
+object Api {
+ @ann({def foo = "foo!!"})
+ def foo = println("foo")
+}
@@ -0,0 +1,3 @@
+object Test extends App {
+ Api.foo
+}

0 comments on commit 9c6a7ad

Please sign in to comment.