diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-14 21:31:21 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-15 02:20:44 +0200 |
commit | 39486b03e1e044fcf3256e1d9293dccd0871edf9 (patch) | |
tree | 1fd266e78572af232a3763ffe0ab5f2df96c4aa5 /src/reflect/scala/reflect/internal/AnnotationInfos.scala | |
parent | 24580ac84242679619d27f20258078dd012c120a (diff) | |
download | scala-39486b03e1e044fcf3256e1d9293dccd0871edf9.tar.gz scala-39486b03e1e044fcf3256e1d9293dccd0871edf9.tar.bz2 scala-39486b03e1e044fcf3256e1d9293dccd0871edf9.zip |
SI-6356 reflection now supports Java annotations
Except for one thingie: java enums are currently not understood
by Scala reflection, hence they aren't yet supported in annotations.
Diffstat (limited to 'src/reflect/scala/reflect/internal/AnnotationInfos.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/AnnotationInfos.scala | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/reflect/scala/reflect/internal/AnnotationInfos.scala b/src/reflect/scala/reflect/internal/AnnotationInfos.scala index 8853b872c0..3bd7f4f4fa 100644 --- a/src/reflect/scala/reflect/internal/AnnotationInfos.scala +++ b/src/reflect/scala/reflect/internal/AnnotationInfos.scala @@ -65,6 +65,7 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => */ abstract class ClassfileAnnotArg extends Product implicit val JavaArgumentTag = ClassTag[ClassfileAnnotArg](classOf[ClassfileAnnotArg]) + case object UnmappableAnnotArg extends ClassfileAnnotArg /** Represents a compile-time Constant (`Boolean`, `Byte`, `Short`, * `Char`, `Int`, `Long`, `Float`, `Double`, `String`, `java.lang.Class` or @@ -173,11 +174,14 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => this } - override def toString = ( - atp + - (if (!args.isEmpty) args.mkString("(", ", ", ")") else "") + - (if (!assocs.isEmpty) (assocs map { case (x, y) => x+" = "+y } mkString ("(", ", ", ")")) else "") - ) + override def toString = completeAnnotationToString(this) + } + + private[scala] def completeAnnotationToString(annInfo: AnnotationInfo) = { + import annInfo._ + val s_args = if (!args.isEmpty) args.mkString("(", ", ", ")") else "" + val s_assocs = if (!assocs.isEmpty) (assocs map { case (x, y) => x+" = "+y } mkString ("(", ", ", ")")) else "" + s"${atp}${s_args}${s_assocs}" } /** Symbol annotations parsed in `Namer` (typeCompleter of @@ -215,7 +219,7 @@ trait AnnotationInfos extends api.Annotations { self: SymbolTable => * * `assocs` stores arguments to classfile annotations as name-value pairs. */ - sealed abstract class AnnotationInfo extends AnnotationApi { + abstract class AnnotationInfo extends AnnotationApi { def atp: Type def args: List[Tree] def assocs: List[(Name, ClassfileAnnotArg)] |