diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-14 14:29:41 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-14 14:29:41 -0800 |
commit | ebdc0ff73b533d2b625a919d0bb57dbe94430c02 (patch) | |
tree | 52cc2d190191b8f2fe4845a52f249458d92ac529 | |
parent | a49722990655633c2c97ddf5699adf25bc8bea76 (diff) | |
download | scala-ebdc0ff73b533d2b625a919d0bb57dbe94430c02.tar.gz scala-ebdc0ff73b533d2b625a919d0bb57dbe94430c02.tar.bz2 scala-ebdc0ff73b533d2b625a919d0bb57dbe94430c02.zip |
Cleaned up meta-annotations.
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.
-rw-r--r-- | src/reflect/scala/reflect/internal/Definitions.scala | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala index eb71574022..edd295aa65 100644 --- a/src/reflect/scala/reflect/internal/Definitions.scala +++ b/src/reflect/scala/reflect/internal/Definitions.scala @@ -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] @@ -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)) |