summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2010-05-04 14:01:58 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2010-05-04 14:01:58 +0000
commit02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596 (patch)
treedca5f24eb228049d81cec52d217d79050614cdbe /src
parent7abeacab53286233d4b150e713ca253c08f38bfd (diff)
downloadscala-02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596.tar.gz
scala-02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596.tar.bz2
scala-02ad6bb9666161e04e0b9ed3a8ffb6b0e2304596.zip
fix and test where constructor parameter annota...
fix and test where constructor parameter annotations end up. no review
Diffstat (limited to 'src')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala16
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))
}
}
}