diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala | 9 | ||||
-rw-r--r-- | test/files/neg/t6375.check | 16 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index 438c783810..b226591c8d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -179,11 +179,12 @@ trait MethodSynthesis { val targetClass = defaultAnnotationTarget(tree) val retained = deriveAnnotations(annotations, targetClass, keepClean = true) - annotations filterNot (retained contains _) foreach (ann => issueAnnotationWarning(ann, targetClass)) + annotations filterNot (retained contains _) foreach (ann => issueAnnotationWarning(tree, ann, targetClass)) } - private def issueAnnotationWarning(ann: AnnotationInfo, defaultTarget: Symbol) { + private def issueAnnotationWarning(tree: Tree, ann: AnnotationInfo, defaultTarget: Symbol) { global.reporter.warning(ann.pos, - s"Annotation is unused - it can be retained with a meta-annotation such as @($ann @${defaultTarget.name})") + s"no valid targets for annotation on ${tree.symbol} - it is discarded unused. " + + s"You may specify targets with meta-annotations, e.g. @($ann @${defaultTarget.name})") } def addDerivedTrees(typer: Typer, stat: Tree): List[Tree] = stat match { @@ -203,7 +204,7 @@ trait MethodSynthesis { // well as fields of the class, etc. if (!mods.isParamAccessor) annotations foreach (ann => if (!trees.exists(_.symbol hasAnnotation ann.symbol)) - issueAnnotationWarning(ann, GetterTargetClass) + issueAnnotationWarning(vd, ann, GetterTargetClass) ) trees diff --git a/test/files/neg/t6375.check b/test/files/neg/t6375.check index b94a067cbb..89d7d8060f 100644 --- a/test/files/neg/t6375.check +++ b/test/files/neg/t6375.check @@ -1,25 +1,25 @@ -t6375.scala:6: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @getter) +t6375.scala:6: warning: no valid targets for annotation on value x1 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @getter) @Bippy val x1: Int // warn ^ -t6375.scala:7: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.field @getter) +t6375.scala:7: warning: no valid targets for annotation on value x2 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.field @getter) @(Bippy @field) val x2: Int // warn ^ -t6375.scala:9: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.setter @getter) +t6375.scala:9: warning: no valid targets for annotation on value x4 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.setter @getter) @(Bippy @setter) val x4: Int // warn ^ -t6375.scala:10: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.param @getter) +t6375.scala:10: warning: no valid targets for annotation on value x5 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.param @getter) @(Bippy @param) val x5: Int // warn ^ -t6375.scala:20: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.getter @field) +t6375.scala:20: warning: no valid targets for annotation on value q1 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.getter @field) @(Bippy @getter) private[this] val q1: Int = 1 // warn ^ -t6375.scala:40: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.getter @param) +t6375.scala:40: warning: no valid targets for annotation on value p2 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.getter @param) @(Bippy @getter) p2: Int, // warn ^ -t6375.scala:41: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.setter @param) +t6375.scala:41: warning: no valid targets for annotation on value p3 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.setter @param) @(Bippy @setter) p3: Int, // warn ^ -t6375.scala:42: warning: Annotation is unused - it can be retained with a meta-annotation such as @(Bippy @scala.annotation.meta.field @param) +t6375.scala:42: warning: no valid targets for annotation on value p4 - it is discarded unused. You may specify targets with meta-annotations, e.g. @(Bippy @scala.annotation.meta.field @param) @(Bippy @field) p4: Int // warn ^ error: No warnings can be incurred under -Xfatal-warnings. |