summaryrefslogtreecommitdiff
path: root/src/compiler/scala/reflect/internal/Symbols.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-11-23 03:11:53 +0000
committerPaul Phillips <paulp@improving.org>2011-11-23 03:11:53 +0000
commit25ecde037f22ff92df5459aaa5360a9760f1f05f (patch)
tree732a46084b7ba949396a6176d6ee1f087ddfadc2 /src/compiler/scala/reflect/internal/Symbols.scala
parentb93c4a9f97c247f80dd222e1a4855165b6daea60 (diff)
downloadscala-25ecde037f22ff92df5459aaa5360a9760f1f05f.tar.gz
scala-25ecde037f22ff92df5459aaa5360a9760f1f05f.tar.bz2
scala-25ecde037f22ff92df5459aaa5360a9760f1f05f.zip
Reworked AnnotationInfo patch.
Took a more ambitious swing based on input from martin. Eliminated the external map and gave annotations a more useful inheritance hierarchy. Eliminated AnnotationInfoBase and made LazyAnnotationInfo an AnnotationInfo (just like LazyType is a Type.) Review by odersky.
Diffstat (limited to 'src/compiler/scala/reflect/internal/Symbols.scala')
-rw-r--r--src/compiler/scala/reflect/internal/Symbols.scala39
1 files changed, 5 insertions, 34 deletions
diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala
index d744cff75a..2fc3eb3652 100644
--- a/src/compiler/scala/reflect/internal/Symbols.scala
+++ b/src/compiler/scala/reflect/internal/Symbols.scala
@@ -1181,56 +1181,27 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
// ----- annotations ------------------------------------------------------------
// null is a marker that they still need to be obtained.
- private var _annotations: List[AnnotationInfo] = null
- // Namer has stored the annotations waiting for us to come calling.
- private def obtainAnnotations() {
- // .initialize: the type completer of the symbol parses the annotations,
- // see "def typeSig" in Namers.
- initialize
- _annotations = pendingSymbolAnnotations remove this match {
- case Some(rawAnnots) =>
- rawAnnots map {
- case x: LazyAnnotationInfo => x.annot()
- case x: AnnotationInfo => x
- } filterNot (_.atp.isError)
- case _ =>
- Nil
- }
- }
- // Gets _annotations without forcing initialization/obtainment.
- def rawAnnotations = if (_annotations eq null) Nil else _annotations
- // Used in namer to check whether annotations were already assigned or not.
- def hasAssignedAnnotations = (_annotations ne null) && _annotations.nonEmpty
+ private var _annotations: List[AnnotationInfo] = Nil
- @deprecated("This method will be removed", "2.10.0")
- def setRawAnnotations(annots: List[AnnotationInfoBase]): this.type = {
- // Just in case this is still in use somewhere.
- pendingSymbolAnnotations(this) = annots
- _annotations = null
- this
- }
+ def annotationsString = if (annotations.isEmpty) "" else annotations.mkString("(", ", ", ")")
/** After the typer phase (before, look at the definition's Modifiers), contains
* the annotations attached to member a definition (class, method, type, field).
*/
- def annotations: List[AnnotationInfo] = {
- if (_annotations eq null)
- obtainAnnotations()
- _annotations
- }
+ def annotations: List[AnnotationInfo] = _annotations
def setAnnotations(annots: List[AnnotationInfo]): this.type = {
_annotations = annots
this
}
def withAnnotations(annots: List[AnnotationInfo]): this.type =
- setAnnotations(annots ::: rawAnnotations)
+ setAnnotations(annots ::: annotations)
def withoutAnnotations: this.type =
setAnnotations(Nil)
def addAnnotation(annot: AnnotationInfo): this.type =
- setAnnotations(annot :: rawAnnotations)
+ setAnnotations(annot :: annotations)
// Convenience for the overwhelmingly common case
def addAnnotation(sym: Symbol, args: Tree*): this.type =