summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/internal/Symbols.scala10
-rwxr-xr-xsrc/library/scala/reflect/api/Symbols.scala2
-rw-r--r--test/files/run/t5423.check1
-rw-r--r--test/files/run/t5423.scala12
4 files changed, 24 insertions, 1 deletions
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala
index 94d764067f..e777491300 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/compiler/scala/reflect/internal/Symbols.scala
@@ -1272,6 +1272,16 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
* the annotations attached to member a definition (class, method, type, field).
*/
def annotations: List[AnnotationInfo] = _annotations
+
+ /** This getter is necessary for reflection, see https://issues.scala-lang.org/browse/SI-5423
+ * We could auto-inject completion into `annotations' and `setAnnotations', but I'm not sure about that
+ * @odersky writes: I fear we can't do the forcing for all compiler symbols as that could introduce cycles
+ */
+ def getAnnotations: List[AnnotationInfo] = {
+ initialize
+ _annotations
+ }
+
def setAnnotations(annots: List[AnnotationInfo]): this.type = {
_annotations = annots
this
diff --git a/src/library/scala/reflect/api/Symbols.scala b/src/library/scala/reflect/api/Symbols.scala
index 01c1a0f2ae..17d9b06324 100755
--- a/src/library/scala/reflect/api/Symbols.scala
+++ b/src/library/scala/reflect/api/Symbols.scala
@@ -79,7 +79,7 @@ trait Symbols { self: Universe =>
/** A list of annotations attached to this Symbol.
*/
- def annotations: List[self.AnnotationInfo]
+ def getAnnotations: List[self.AnnotationInfo]
/** For a class: the module or case class factory with the same name in the same package.
* For all others: NoSymbol
diff --git a/test/files/run/t5423.check b/test/files/run/t5423.check
new file mode 100644
index 0000000000..ae3d3fb82b
--- /dev/null
+++ b/test/files/run/t5423.check
@@ -0,0 +1 @@
+List(table) \ No newline at end of file
diff --git a/test/files/run/t5423.scala b/test/files/run/t5423.scala
new file mode 100644
index 0000000000..2139773ff1
--- /dev/null
+++ b/test/files/run/t5423.scala
@@ -0,0 +1,12 @@
+import java.lang.Class
+import scala.reflect.mirror._
+import scala.reflect.runtime.Mirror.ToolBox
+import scala.reflect.Code
+
+final class table extends StaticAnnotation
+@table class A
+
+object Test extends App{
+ val s = classToSymbol(classOf[A])
+ println(s.getAnnotations)
+}