diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-05-05 11:53:31 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-05-05 11:53:31 +0000 |
commit | c2002c83615b4a1228a66f7aea1dc3e5d5441420 (patch) | |
tree | 5e2734ff21d49cef27d5584cf2ee482b14e4416a /src | |
parent | dabf2c23ef61092adb3490100442b684611e3c93 (diff) | |
download | scala-c2002c83615b4a1228a66f7aea1dc3e5d5441420.tar.gz scala-c2002c83615b4a1228a66f7aea1dc3e5d5441420.tar.bz2 scala-c2002c83615b4a1228a66f7aea1dc3e5d5441420.zip |
revert the revert of r21791 (fix constructor pa...
revert the revert of r21791 (fix constructor parameter annotations).
close #3390. together with a new starr it builds. no review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 92dd368ac5..f503a797bb 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1330,7 +1330,9 @@ trait Typers { self: Analyzer => val value = stat.symbol val allAnnots = value.annotations if (!isDeferred) - value.setAnnotations(memberAnnots(allAnnots, FieldTargetClass)) + // keepClean: by default annotations go to the field, except if the field is + // generated for a class parameter (PARAMACCESSOR). + value.setAnnotations(memberAnnots(allAnnots, FieldTargetClass, keepClean = !mods.hasFlag(PARAMACCESSOR))) val getter = if (isDeferred) value else value.getter(value.owner) assert(getter != NoSymbol, stat) @@ -1410,10 +1412,12 @@ trait Typers { self: Analyzer => List(stat) } - /** The annotations amongst `annots` that should go on a member of class - * `memberClass` (field, getter, setter, beanGetter, beanSetter, param) + /** + * The annotations amongst `annots` that should go on a member of class + * `memberClass` (field, getter, setter, beanGetter, beanSetter, param) + * If 'keepClean' is true, annotations without any meta-annotation are kept */ - protected def memberAnnots(annots: List[AnnotationInfo], memberClass: Symbol) = { + protected def memberAnnots(annots: List[AnnotationInfo], memberClass: Symbol, keepClean: Boolean = false) = { def hasMatching(metaAnnots: List[AnnotationInfo], orElse: => Boolean) = { // either one of the meta-annotations matches the `memberClass` @@ -1430,7 +1434,7 @@ trait Typers { self: Analyzer => // there was no meta-annotation on `ann`. Look if the class annotations of // `ann` has a `target` annotation, otherwise put `ann` only on fields. def noMetaAnnot(ann: AnnotationInfo) = { - hasMatching(ann.atp.typeSymbol.annotations, memberClass == FieldTargetClass) + hasMatching(ann.atp.typeSymbol.annotations, keepClean) } annots.filter(ann => ann.atp match { @@ -1702,7 +1706,7 @@ trait Typers { self: Analyzer => for (vparams <- ddef.vparamss; vd <- vparams) { if (vd hasFlag PARAMACCESSOR) { val sym = vd.symbol - sym.setAnnotations(memberAnnots(sym.annotations, ParamTargetClass)) + sym.setAnnotations(memberAnnots(sym.annotations, ParamTargetClass, keepClean = true)) } } } |