Skip to content

Commit

Permalink
Cleaned up meta-annotations.
Browse files Browse the repository at this point in the history
There were some missing and some others not added to the
set of meta-annotations. I added the missing ones and
defined the set in such a way as to include them all, even
those which have not yet been born.
  • Loading branch information
paulp committed Jan 14, 2013
1 parent a497229 commit ebdc0ff
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/reflect/scala/reflect/internal/Definitions.scala
Expand Up @@ -901,6 +901,7 @@ trait Definitions extends api.StandardDefinitions {
lazy val GetterTargetClass = requiredClass[meta.getter]
lazy val ParamTargetClass = requiredClass[meta.param]
lazy val SetterTargetClass = requiredClass[meta.setter]
lazy val ObjectTargetClass = requiredClass[meta.companionObject]
lazy val ClassTargetClass = requiredClass[meta.companionClass]
lazy val MethodTargetClass = requiredClass[meta.companionMethod] // TODO: module, moduleClass? package, packageObject?
lazy val LanguageFeatureAnnot = requiredClass[meta.languageFeature]
Expand All @@ -920,11 +921,21 @@ trait Definitions extends api.StandardDefinitions {
// Trying to allow for deprecated locations
sym.isAliasType && isMetaAnnotation(sym.info.typeSymbol)
)
lazy val metaAnnotations = Set[Symbol](
FieldTargetClass, ParamTargetClass,
GetterTargetClass, SetterTargetClass,
BeanGetterTargetClass, BeanSetterTargetClass
)
lazy val metaAnnotations: Set[Symbol] = getPackage("scala.annotation.meta").info.members filter (_ isSubClass StaticAnnotationClass) toSet

// According to the scala.annotation.meta package object:
// * By default, annotations on (`val`-, `var`- or plain) constructor parameters
// * end up on the parameter, not on any other entity. Annotations on fields
// * by default only end up on the field.
def defaultAnnotationTarget(t: Tree): Symbol = t match {
case ClassDef(_, _, _, _) => ClassTargetClass
case ModuleDef(_, _, _) => ObjectTargetClass
case vd @ ValDef(_, _, _, _) if vd.symbol.isParamAccessor => ParamTargetClass
case vd @ ValDef(_, _, _, _) if vd.symbol.isValueParameter => ParamTargetClass
case ValDef(_, _, _, _) => FieldTargetClass
case DefDef(_, _, _, _, _, _) => MethodTargetClass
case _ => GetterTargetClass
}

lazy val AnnotationDefaultAttr: ClassSymbol = {
val attr = enterNewClass(RuntimePackageClass, tpnme.AnnotationDefaultATTR, List(AnnotationClass.tpe))
Expand Down

0 comments on commit ebdc0ff

Please sign in to comment.