summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Typers.scala
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2013-01-13 14:28:33 +0100
committerJason Zaugg <jzaugg@gmail.com>2013-01-13 14:28:33 +0100
commit39352fe0f3048e86b339db4b40851a9f27c7a6ef (patch)
tree61b2a320eaed14eb14531321a4ce0d5f020f02c8 /src/compiler/scala/tools/nsc/typechecker/Typers.scala
parent5d65772762072aa950a488c666673dc248b01d6d (diff)
downloadscala-39352fe0f3048e86b339db4b40851a9f27c7a6ef.tar.gz
scala-39352fe0f3048e86b339db4b40851a9f27c7a6ef.tar.bz2
scala-39352fe0f3048e86b339db4b40851a9f27c7a6ef.zip
SI-6082 Conditionally expand @ann(x) to @ann(value = x)
... if the annotation has an argument with the name `value`. Doing so unconditionally obscures error messages. We still require that arguments to ClassFileAnnotations are named, other than for this special case.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Typers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 386eec207a..0ca1e01114 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -3637,15 +3637,18 @@ trait Typers extends Modes with Adaptations with Tags {
} else if (argss.length > 1) {
reportAnnotationError(MultipleArgumentListForAnnotationError(ann))
} else {
- val args =
- if (argss.head.length == 1 && !isNamed(argss.head.head))
- List(new AssignOrNamedArg(Ident(nme.value), argss.head.head))
- else argss.head
val annScope = annType.decls
.filter(sym => sym.isMethod && !sym.isConstructor && sym.isJavaDefined)
val names = new scala.collection.mutable.HashSet[Symbol]
+ def hasValue = names exists (_.name == nme.value)
names ++= (if (isJava) annScope.iterator
else typedFun.tpe.params.iterator)
+ val args = argss match {
+ case List(List(arg)) if !isNamed(arg) && hasValue =>
+ List(new AssignOrNamedArg(Ident(nme.value), arg))
+ case as :: _ => as
+ }
+
val nvPairs = args map {
case arg @ AssignOrNamedArg(Ident(name), rhs) =>
val sym = if (isJava) annScope.lookup(name)