summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala2
-rw-r--r--src/compiler/scala/reflect/reify/codegen/GenUtils.scala3
-rw-r--r--src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala4
-rw-r--r--src/library/scala/reflect/base/AnnotationInfos.scala44
-rw-r--r--src/library/scala/reflect/base/Annotations.scala46
-rw-r--r--src/library/scala/reflect/base/Base.scala33
-rw-r--r--src/library/scala/reflect/base/BuildUtils.scala2
-rw-r--r--src/library/scala/reflect/base/Types.scala4
-rw-r--r--src/library/scala/reflect/base/Universe.scala2
-rw-r--r--src/reflect/scala/reflect/api/AnnotationInfos.scala27
-rw-r--r--src/reflect/scala/reflect/api/Annotations.scala29
-rw-r--r--src/reflect/scala/reflect/api/Symbols.scala4
-rw-r--r--src/reflect/scala/reflect/api/Types.scala2
-rw-r--r--src/reflect/scala/reflect/api/Universe.scala2
-rw-r--r--src/reflect/scala/reflect/internal/AnnotationInfos.scala73
-rw-r--r--src/reflect/scala/reflect/internal/StdNames.scala2
-rw-r--r--src/reflect/scala/reflect/internal/pickling/UnPickler.scala2
-rw-r--r--src/reflect/scala/reflect/macros/Universe.scala2
18 files changed, 155 insertions, 128 deletions
diff --git a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala
index 5f4296f54f..dec491aabe 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenAnnotationInfos.scala
@@ -50,6 +50,6 @@ trait GenAnnotationInfos {
// if you reify originals of anns, you get SO when trying to reify AnnotatedTypes, so screw it - after all, it's not that important
val reifiedAssocs = ann.assocs map (assoc => scalaFactoryCall(nme.Tuple2, reify(assoc._1), reifyClassfileAnnotArg(assoc._2)))
- mirrorFactoryCall(nme.AnnotationInfo, reify(ann.atp), mkList(reifiedArgs), mkList(reifiedAssocs))
+ mirrorFactoryCall(nme.Annotation, reify(ann.atp), mkList(reifiedArgs), mkListMap(reifiedAssocs))
}
} \ No newline at end of file
diff --git a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
index 8aef8d772f..49877b4286 100644
--- a/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
+++ b/src/compiler/scala/reflect/reify/codegen/GenUtils.scala
@@ -70,6 +70,9 @@ trait GenUtils {
def mkList(args: List[Tree]): Tree =
scalaFactoryCall("collection.immutable.List", args: _*)
+ def mkListMap(args: List[Tree]): Tree =
+ scalaFactoryCall("collection.immutable.ListMap", args: _*)
+
/**
* An (unreified) path that refers to definition with given fully qualified name
* @param mkName Creator for last portion of name (either TermName or TypeName)
diff --git a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
index 002cf0c5e8..a987da8ba6 100644
--- a/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
+++ b/src/compiler/scala/tools/nsc/doc/model/ModelFactory.scala
@@ -894,9 +894,9 @@ class ModelFactory(val global: Global, val settings: doc.Settings) {
}
/** */
- def makeAnnotation(annot: AnnotationInfo): Annotation = {
+ def makeAnnotation(annot: AnnotationInfo): scala.tools.nsc.doc.model.Annotation = {
val aSym = annot.symbol
- new EntityImpl(aSym, makeTemplate(aSym.owner)) with Annotation {
+ new EntityImpl(aSym, makeTemplate(aSym.owner)) with scala.tools.nsc.doc.model.Annotation {
lazy val annotationClass =
makeTemplate(annot.symbol)
val arguments = { // lazy
diff --git a/src/library/scala/reflect/base/AnnotationInfos.scala b/src/library/scala/reflect/base/AnnotationInfos.scala
deleted file mode 100644
index f03644deef..0000000000
--- a/src/library/scala/reflect/base/AnnotationInfos.scala
+++ /dev/null
@@ -1,44 +0,0 @@
-package scala.reflect
-package base
-
-trait AnnotationInfos { self: Universe =>
-
- type AnnotationInfo >: Null <: AnyRef
- implicit val AnnotationInfoTag: ClassTag[AnnotationInfo]
- val AnnotationInfo: AnnotationInfoExtractor
-
- abstract class AnnotationInfoExtractor {
- def apply(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)]): AnnotationInfo
- def unapply(info: AnnotationInfo): Option[(Type, List[Tree], List[(Name, ClassfileAnnotArg)])]
- }
-
- type ClassfileAnnotArg >: Null <: AnyRef
- implicit val ClassfileAnnotArgTag: ClassTag[ClassfileAnnotArg]
-
- type LiteralAnnotArg >: Null <: AnyRef with ClassfileAnnotArg
- implicit val LiteralAnnotArgTag: ClassTag[LiteralAnnotArg]
- val LiteralAnnotArg: LiteralAnnotArgExtractor
-
- abstract class LiteralAnnotArgExtractor {
- def apply(const: Constant): LiteralAnnotArg
- def unapply(arg: LiteralAnnotArg): Option[Constant]
- }
-
- type ArrayAnnotArg >: Null <: AnyRef with ClassfileAnnotArg
- implicit val ArrayAnnotArgTag: ClassTag[ArrayAnnotArg]
- val ArrayAnnotArg: ArrayAnnotArgExtractor
-
- abstract class ArrayAnnotArgExtractor {
- def apply(args: Array[ClassfileAnnotArg]): ArrayAnnotArg
- def unapply(arg: ArrayAnnotArg): Option[Array[ClassfileAnnotArg]]
- }
-
- type NestedAnnotArg >: Null <: AnyRef with ClassfileAnnotArg
- implicit val NestedAnnotArgTag: ClassTag[NestedAnnotArg]
- val NestedAnnotArg: NestedAnnotArgExtractor
-
- abstract class NestedAnnotArgExtractor {
- def apply(annInfo: AnnotationInfo): NestedAnnotArg
- def unapply(arg: NestedAnnotArg): Option[AnnotationInfo]
- }
-} \ No newline at end of file
diff --git a/src/library/scala/reflect/base/Annotations.scala b/src/library/scala/reflect/base/Annotations.scala
new file mode 100644
index 0000000000..e3453b1cdf
--- /dev/null
+++ b/src/library/scala/reflect/base/Annotations.scala
@@ -0,0 +1,46 @@
+package scala.reflect
+package base
+
+import scala.collection.immutable.ListMap
+
+trait Annotations { self: Universe =>
+
+ type Annotation >: Null <: AnyRef
+ implicit val AnnotationTag: ClassTag[Annotation]
+ val Annotation: AnnotationExtractor
+
+ abstract class AnnotationExtractor {
+ def apply(tpe: Type, scalaArgs: List[Tree], javaArgs: ListMap[Name, JavaArgument]): Annotation
+ def unapply(ann: Annotation): Option[(Type, List[Tree], ListMap[Name, JavaArgument])]
+ }
+
+ type JavaArgument >: Null <: AnyRef
+ implicit val JavaArgumentTag: ClassTag[JavaArgument]
+
+ type LiteralArgument >: Null <: AnyRef with JavaArgument
+ implicit val LiteralArgumentTag: ClassTag[LiteralArgument]
+ val LiteralArgument: LiteralArgumentExtractor
+
+ abstract class LiteralArgumentExtractor {
+ def apply(value: Constant): LiteralArgument
+ def unapply(arg: LiteralArgument): Option[Constant]
+ }
+
+ type ArrayArgument >: Null <: AnyRef with JavaArgument
+ implicit val ArrayArgumentTag: ClassTag[ArrayArgument]
+ val ArrayArgument: ArrayArgumentExtractor
+
+ abstract class ArrayArgumentExtractor {
+ def apply(args: Array[JavaArgument]): ArrayArgument
+ def unapply(arg: ArrayArgument): Option[Array[JavaArgument]]
+ }
+
+ type NestedArgument >: Null <: AnyRef with JavaArgument
+ implicit val NestedArgumentTag: ClassTag[NestedArgument]
+ val NestedArgument: NestedArgumentExtractor
+
+ abstract class NestedArgumentExtractor {
+ def apply(annotation: Annotation): NestedArgument
+ def unapply(arg: NestedArgument): Option[Annotation]
+ }
+} \ No newline at end of file
diff --git a/src/library/scala/reflect/base/Base.scala b/src/library/scala/reflect/base/Base.scala
index 65e9f4c335..29bf2df656 100644
--- a/src/library/scala/reflect/base/Base.scala
+++ b/src/library/scala/reflect/base/Base.scala
@@ -5,6 +5,7 @@ import java.io.PrintWriter
import scala.annotation.switch
import scala.ref.WeakReference
import scala.collection.mutable
+import scala.collection.immutable.ListMap
class Base extends Universe { self =>
@@ -157,7 +158,7 @@ class Base extends Universe { self =>
object ExistentialType extends ExistentialTypeExtractor
implicit val ExistentialTypeTag = ClassTag[ExistentialType](classOf[ExistentialType])
- case class AnnotatedType(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol) extends Type { override def typeSymbol = underlying.typeSymbol }
+ case class AnnotatedType(annotations: List[Annotation], underlying: Type, selfsym: Symbol) extends Type { override def typeSymbol = underlying.typeSymbol }
object AnnotatedType extends AnnotatedTypeExtractor
implicit val AnnotatedTypeTag = ClassTag[AnnotatedType](classOf[AnnotatedType])
@@ -249,24 +250,24 @@ class Base extends Universe { self =>
object Constant extends ConstantExtractor
implicit val ConstantTag = ClassTag[Constant](classOf[Constant])
- case class AnnotationInfo(atp: Type, args: List[Tree], assocs: List[(Name, ClassfileAnnotArg)])
- object AnnotationInfo extends AnnotationInfoExtractor
- implicit val AnnotationInfoTag = ClassTag[AnnotationInfo](classOf[AnnotationInfo])
+ case class Annotation(tpe: Type, scalaArgs: List[Tree], javaArgs: ListMap[Name, JavaArgument])
+ object Annotation extends AnnotationExtractor
+ implicit val AnnotationTag = ClassTag[Annotation](classOf[Annotation])
- abstract class ClassfileAnnotArg
- implicit val ClassfileAnnotArgTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
+ abstract class JavaArgument
+ implicit val JavaArgumentTag = ClassTag[JavaArgument](classOf[JavaArgument])
- case class LiteralAnnotArg(const: Constant) extends ClassfileAnnotArg
- object LiteralAnnotArg extends LiteralAnnotArgExtractor
- implicit val LiteralAnnotArgTag = ClassTag[LiteralAnnotArg](classOf[LiteralAnnotArg])
+ case class LiteralArgument(value: Constant) extends JavaArgument
+ object LiteralArgument extends LiteralArgumentExtractor
+ implicit val LiteralArgumentTag = ClassTag[LiteralArgument](classOf[LiteralArgument])
- case class ArrayAnnotArg(args: Array[ClassfileAnnotArg]) extends ClassfileAnnotArg
- object ArrayAnnotArg extends ArrayAnnotArgExtractor
- implicit val ArrayAnnotArgTag = ClassTag[ArrayAnnotArg](classOf[ArrayAnnotArg])
+ case class ArrayArgument(args: Array[JavaArgument]) extends JavaArgument
+ object ArrayArgument extends ArrayArgumentExtractor
+ implicit val ArrayArgumentTag = ClassTag[ArrayArgument](classOf[ArrayArgument])
- case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg
- object NestedAnnotArg extends NestedAnnotArgExtractor
- implicit val NestedAnnotArgTag = ClassTag[NestedAnnotArg](classOf[NestedAnnotArg])
+ case class NestedArgument(annotation: Annotation) extends JavaArgument
+ object NestedArgument extends NestedArgumentExtractor
+ implicit val NestedArgumentTag = ClassTag[NestedArgument](classOf[NestedArgument])
class Position extends Attachments {
override type Pos = Position
@@ -319,7 +320,7 @@ class Base extends Universe { self =>
def setTypeSignature[S <: Symbol](sym: S, tpe: Type): S = sym
- def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S = sym
+ def setAnnotations[S <: Symbol](sym: S, annots: List[Annotation]): S = sym
def flagsFromBits(bits: Long): FlagSet = bits
diff --git a/src/library/scala/reflect/base/BuildUtils.scala b/src/library/scala/reflect/base/BuildUtils.scala
index c4231dd515..e4710316e2 100644
--- a/src/library/scala/reflect/base/BuildUtils.scala
+++ b/src/library/scala/reflect/base/BuildUtils.scala
@@ -49,7 +49,7 @@ trait BuildUtils { self: Universe =>
/** Set symbol's annotations to given annotations `annots`.
*/
- def setAnnotations[S <: Symbol](sym: S, annots: List[AnnotationInfo]): S
+ def setAnnotations[S <: Symbol](sym: S, annots: List[Annotation]): S
def flagsFromBits(bits: Long): FlagSet
diff --git a/src/library/scala/reflect/base/Types.scala b/src/library/scala/reflect/base/Types.scala
index b016b77f36..839c49805a 100644
--- a/src/library/scala/reflect/base/Types.scala
+++ b/src/library/scala/reflect/base/Types.scala
@@ -362,8 +362,8 @@ trait Types { self: Universe =>
* `selfSym` is a symbol representing the annotated type itself.
*/
abstract class AnnotatedTypeExtractor {
- def apply(annotations: List[AnnotationInfo], underlying: Type, selfsym: Symbol): AnnotatedType
- def unapply(tpe: AnnotatedType): Option[(List[AnnotationInfo], Type, Symbol)]
+ def apply(annotations: List[Annotation], underlying: Type, selfsym: Symbol): AnnotatedType
+ def unapply(tpe: AnnotatedType): Option[(List[Annotation], Type, Symbol)]
}
/** The `TypeBounds` type signature is used to indicate lower and upper type bounds
diff --git a/src/library/scala/reflect/base/Universe.scala b/src/library/scala/reflect/base/Universe.scala
index 18599ad092..11290401ec 100644
--- a/src/library/scala/reflect/base/Universe.scala
+++ b/src/library/scala/reflect/base/Universe.scala
@@ -8,7 +8,7 @@ abstract class Universe extends Symbols
with Names
with Trees
with Constants
- with AnnotationInfos
+ with Annotations
with Positions
with Exprs
with TypeTags
diff --git a/src/reflect/scala/reflect/api/AnnotationInfos.scala b/src/reflect/scala/reflect/api/AnnotationInfos.scala
deleted file mode 100644
index d9f35024d9..0000000000
--- a/src/reflect/scala/reflect/api/AnnotationInfos.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-package scala.reflect
-package api
-
-trait AnnotationInfos extends base.AnnotationInfos { self: Universe =>
-
- override type AnnotationInfo >: Null <: AnyRef with AnnotationInfoApi
- trait AnnotationInfoApi {
- def atp: Type
- def args: List[Tree]
- def assocs: List[(Name, ClassfileAnnotArg)]
- }
-
- override type LiteralAnnotArg >: Null <: ClassfileAnnotArg with LiteralAnnotArgApi
- trait LiteralAnnotArgApi {
- def const: Constant
- }
-
- override type ArrayAnnotArg >: Null <: ClassfileAnnotArg with ArrayAnnotArgApi
- trait ArrayAnnotArgApi {
- def args: Array[ClassfileAnnotArg]
- }
-
- override type NestedAnnotArg >: Null <: ClassfileAnnotArg with NestedAnnotArgApi
- trait NestedAnnotArgApi {
- def annInfo: AnnotationInfo
- }
-} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/api/Annotations.scala b/src/reflect/scala/reflect/api/Annotations.scala
new file mode 100644
index 0000000000..43e95f9902
--- /dev/null
+++ b/src/reflect/scala/reflect/api/Annotations.scala
@@ -0,0 +1,29 @@
+package scala.reflect
+package api
+
+import scala.collection.immutable.ListMap
+
+trait Annotations extends base.Annotations { self: Universe =>
+
+ override type Annotation >: Null <: AnyRef with AnnotationApi
+ trait AnnotationApi {
+ def tpe: Type
+ def scalaArgs: List[Tree]
+ def javaArgs: ListMap[Name, JavaArgument]
+ }
+
+ override type LiteralArgument >: Null <: JavaArgument with LiteralArgumentApi
+ trait LiteralArgumentApi {
+ def value: Constant
+ }
+
+ override type ArrayArgument >: Null <: JavaArgument with ArrayArgumentApi
+ trait ArrayArgumentApi {
+ def args: Array[JavaArgument]
+ }
+
+ override type NestedArgument >: Null <: JavaArgument with NestedArgumentApi
+ trait NestedArgumentApi {
+ def annotation: Annotation
+ }
+} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/api/Symbols.scala b/src/reflect/scala/reflect/api/Symbols.scala
index 08680ca815..cf1f574ade 100644
--- a/src/reflect/scala/reflect/api/Symbols.scala
+++ b/src/reflect/scala/reflect/api/Symbols.scala
@@ -36,8 +36,8 @@ trait Symbols extends base.Symbols { self: Universe =>
// at scala.reflect.internal.pickling.UnPickler$Scan.run(UnPickler.scala:88)
// at scala.reflect.internal.pickling.UnPickler.unpickle(UnPickler.scala:37)
// at scala.reflect.runtime.JavaMirrors$JavaMirror.unpickleClass(JavaMirrors.scala:253) // unpickle from within a reflexive mirror
- // def annotations: List[AnnotationInfo]
- def getAnnotations: List[AnnotationInfo]
+ // def annotations: List[Annotation]
+ def getAnnotations: List[Annotation]
/** For a class: the module or case class factory with the same name in the same package.
* For a module: the class with the same name in the same package.
diff --git a/src/reflect/scala/reflect/api/Types.scala b/src/reflect/scala/reflect/api/Types.scala
index fab4e5d0a9..1c79de02c3 100644
--- a/src/reflect/scala/reflect/api/Types.scala
+++ b/src/reflect/scala/reflect/api/Types.scala
@@ -255,7 +255,7 @@ trait Types extends base.Types { self: Universe =>
/** The API that all annotated types support */
trait AnnotatedTypeApi extends TypeApi { this: AnnotatedType =>
- val annotations: List[AnnotationInfo]
+ val annotations: List[Annotation]
val underlying: Type
val selfsym: Symbol
}
diff --git a/src/reflect/scala/reflect/api/Universe.scala b/src/reflect/scala/reflect/api/Universe.scala
index 3dce0f218e..3165f9abcd 100644
--- a/src/reflect/scala/reflect/api/Universe.scala
+++ b/src/reflect/scala/reflect/api/Universe.scala
@@ -14,4 +14,4 @@ abstract class Universe extends base.Universe
with StandardDefinitions
with StandardNames
with Importers
- with AnnotationInfos
+ with Annotations
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
index a444c786f7..8853b872c0 100644
--- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala
+++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala
@@ -9,9 +9,10 @@ package internal
import util._
import pickling.ByteCodecs
import scala.annotation.tailrec
+import scala.collection.immutable.ListMap
/** AnnotationInfo and its helpers */
-trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
+trait AnnotationInfos extends api.Annotations { self: SymbolTable =>
import definitions.{ ThrowsClass, StaticAnnotationClass, isMetaAnnotation }
// Common annotation code between Symbol and Type.
@@ -32,7 +33,7 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
case AnnotationInfo(tp, Literal(Constant(tpe: Type)) :: Nil, _) if tp.typeSymbol == ThrowsClass => tpe.typeSymbol
}
- /** Tests for, get, or remove an annotation */
+ /** Tests for, get, or remove an annotation */
def hasAnnotation(cls: Symbol): Boolean =
//OPT inlined from exists to save on #closures; was: annotations exists (_ matches cls)
dropOtherAnnotations(annotations, cls).nonEmpty
@@ -43,12 +44,12 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
case ann :: _ => Some(ann)
case _ => None
}
-
+
def removeAnnotation(cls: Symbol): Self = filterAnnotations(ann => !(ann matches cls))
-
+
final def withAnnotation(annot: AnnotationInfo): Self = withAnnotations(List(annot))
- @tailrec private
+ @tailrec private
def dropOtherAnnotations(anns: List[AnnotationInfo], cls: Symbol): List[AnnotationInfo] = anns match {
case ann :: rest => if (ann matches cls) anns else dropOtherAnnotations(rest, cls)
case Nil => Nil
@@ -63,28 +64,46 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
* - or nested classfile annotations
*/
abstract class ClassfileAnnotArg extends Product
- implicit val ClassfileAnnotArgTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
+ implicit val JavaArgumentTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg])
/** Represents a compile-time Constant (`Boolean`, `Byte`, `Short`,
* `Char`, `Int`, `Long`, `Float`, `Double`, `String`, `java.lang.Class` or
* an instance of a Java enumeration value).
*/
case class LiteralAnnotArg(const: Constant)
- extends ClassfileAnnotArg with LiteralAnnotArgApi {
+ extends ClassfileAnnotArg with LiteralArgumentApi {
+ def value = const
override def toString = const.escapedStringValue
}
- implicit val LiteralAnnotArgTag = ClassTag[LiteralAnnotArg](classOf[LiteralAnnotArg])
-
- object LiteralAnnotArg extends LiteralAnnotArgExtractor
+ object LiteralAnnotArg extends LiteralArgumentExtractor
/** Represents an array of classfile annotation arguments */
case class ArrayAnnotArg(args: Array[ClassfileAnnotArg])
- extends ClassfileAnnotArg with ArrayAnnotArgApi {
+ extends ClassfileAnnotArg with ArrayArgumentApi {
override def toString = args.mkString("[", ", ", "]")
}
- implicit val ArrayAnnotArgTag = ClassTag[ArrayAnnotArg](classOf[ArrayAnnotArg])
+ object ArrayAnnotArg extends ArrayArgumentExtractor
- object ArrayAnnotArg extends ArrayAnnotArgExtractor
+ /** Represents a nested classfile annotation */
+ case class NestedAnnotArg(annInfo: AnnotationInfo)
+ extends ClassfileAnnotArg with NestedArgumentApi {
+ // The nested annotation should not have any Scala annotation arguments
+ assert(annInfo.args.isEmpty, annInfo.args)
+ def annotation = annInfo
+ override def toString = annInfo.toString
+ }
+ object NestedAnnotArg extends NestedArgumentExtractor
+
+ type JavaArgument = ClassfileAnnotArg
+ type LiteralArgument = LiteralAnnotArg
+ val LiteralArgument = LiteralAnnotArg
+ implicit val LiteralArgumentTag = ClassTag[LiteralAnnotArg](classOf[LiteralAnnotArg])
+ type ArrayArgument = ArrayAnnotArg
+ val ArrayArgument = ArrayAnnotArg
+ implicit val ArrayArgumentTag = ClassTag[ArrayAnnotArg](classOf[ArrayAnnotArg])
+ type NestedArgument = NestedAnnotArg
+ val NestedArgument = NestedAnnotArg
+ implicit val NestedArgumentTag = ClassTag[NestedAnnotArg](classOf[NestedAnnotArg])
/** A specific annotation argument that encodes an array of bytes as an
* array of `Long`. The type of the argument declared in the annotation
@@ -121,20 +140,9 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
}
src
}
-
}
- /** Represents a nested classfile annotation */
- case class NestedAnnotArg(annInfo: AnnotationInfo) extends ClassfileAnnotArg with NestedAnnotArgApi {
- // The nested annotation should not have any Scala annotation arguments
- assert(annInfo.args.isEmpty, annInfo.args)
- override def toString = annInfo.toString
- }
- implicit val NestedAnnotArgTag = ClassTag[NestedAnnotArg](classOf[NestedAnnotArg])
-
- object NestedAnnotArg extends NestedAnnotArgExtractor
-
- object AnnotationInfo extends AnnotationInfoExtractor {
+ object AnnotationInfo {
def marker(atp: Type): AnnotationInfo =
apply(atp, Nil, Nil)
@@ -207,11 +215,15 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
*
* `assocs` stores arguments to classfile annotations as name-value pairs.
*/
- sealed abstract class AnnotationInfo extends AnnotationInfoApi {
+ sealed abstract class AnnotationInfo extends AnnotationApi {
def atp: Type
def args: List[Tree]
def assocs: List[(Name, ClassfileAnnotArg)]
+ def tpe = atp
+ def scalaArgs = args
+ def javaArgs = ListMap(assocs: _*)
+
// necessary for reification, see Reifiers.scala for more info
def original: Tree
def setOriginal(t: Tree): this.type
@@ -299,7 +311,14 @@ trait AnnotationInfos extends api.AnnotationInfos { self: SymbolTable =>
}
}
- implicit val AnnotationInfoTag = ClassTag[AnnotationInfo](classOf[AnnotationInfo])
+ type Annotation = AnnotationInfo
+ object Annotation extends AnnotationExtractor {
+ def apply(tpe: Type, scalaArgs: List[Tree], javaArgs: ListMap[Name, ClassfileAnnotArg]): Annotation =
+ AnnotationInfo(tpe, scalaArgs, javaArgs.toList)
+ def unapply(annotation: Annotation): Option[(Type, List[Tree], ListMap[Name, ClassfileAnnotArg])] =
+ Some((annotation.tpe, annotation.scalaArgs, annotation.javaArgs))
+ }
+ implicit val AnnotationTag = ClassTag[AnnotationInfo](classOf[AnnotationInfo])
object UnmappableAnnotation extends CompleteAnnotationInfo(NoType, Nil, Nil)
}
diff --git a/src/reflect/scala/reflect/internal/StdNames.scala b/src/reflect/scala/reflect/internal/StdNames.scala
index e70531df6e..22f5b391b8 100644
--- a/src/reflect/scala/reflect/internal/StdNames.scala
+++ b/src/reflect/scala/reflect/internal/StdNames.scala
@@ -571,7 +571,7 @@ trait StdNames {
// Compiler utilized names
val AnnotatedType: NameType = "AnnotatedType"
- val AnnotationInfo: NameType = "AnnotationInfo"
+ val Annotation: NameType = "Annotation"
val Any: NameType = "Any"
val AnyVal: NameType = "AnyVal"
val AppliedTypeTree: NameType = "AppliedTypeTree"
diff --git a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
index 1dae6e70b7..a9994a037f 100644
--- a/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
+++ b/src/reflect/scala/reflect/internal/pickling/UnPickler.scala
@@ -446,7 +446,7 @@ abstract class UnPickler /*extends scala.reflect.generic.UnPickler*/ {
private def readArrayAnnot() = {
readByte() // skip the `annotargarray` tag
val end = readNat() + readIndex
- until(end, () => readClassfileAnnotArg(readNat())).toArray(ClassfileAnnotArgTag)
+ until(end, () => readClassfileAnnotArg(readNat())).toArray(JavaArgumentTag)
}
protected def readClassfileAnnotArg(i: Int): ClassfileAnnotArg = bytes(index(i)) match {
case ANNOTINFO => NestedAnnotArg(at(i, readAnnotation))
diff --git a/src/reflect/scala/reflect/macros/Universe.scala b/src/reflect/scala/reflect/macros/Universe.scala
index f6a4ef6c9b..7fa2e7cbae 100644
--- a/src/reflect/scala/reflect/macros/Universe.scala
+++ b/src/reflect/scala/reflect/macros/Universe.scala
@@ -32,7 +32,7 @@ abstract class Universe extends scala.reflect.api.Universe {
def setTypeSignature(tpe: Type): Symbol
- def setAnnotations(annots: AnnotationInfo*): Symbol
+ def setAnnotations(annots: Annotation*): Symbol
def setName(name: Name): Symbol