summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala13
-rw-r--r--test/files/neg/t5182.check7
-rw-r--r--test/files/neg/t5182.flags1
-rw-r--r--test/files/neg/t5182.scala5
4 files changed, 20 insertions, 6 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index c12233b726..162bdd22b2 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -117,6 +117,10 @@ trait Typers extends Adaptations with Tags {
}
}
+ private def mkNamedArg(tree: Tree, name: Name): Tree = {
+ atPos(tree.pos)(new AssignOrNamedArg(Ident(name), tree))
+ }
+
/** Find implicit arguments and pass them to given tree.
*/
def applyImplicitArgs(fun: Tree): Tree = fun.tpe match {
@@ -128,7 +132,6 @@ trait Typers extends Adaptations with Tags {
var paramFailed = false
def mkPositionalArg(argTree: Tree, paramName: Name) = argTree
- def mkNamedArg(argTree: Tree, paramName: Name) = atPos(argTree.pos)(new AssignOrNamedArg(Ident(paramName), (argTree)))
var mkArg: (Tree, Name) => Tree = mkPositionalArg
// DEPMETTODO: instantiate type vars that depend on earlier implicit args (see adapt (4.1))
@@ -3459,7 +3462,7 @@ trait Typers extends Adaptations with Tags {
// begin typedAnnotation
val treeInfo.Applied(fun0, targs, argss) = treeInfo.dissectApplied(ann)
- val typedFun0 = typed(fun0, forFunMode(mode), WildcardType)
+ val typedFun0 = typed(fun0, mode.forFunMode, WildcardType)
val typedFunPart = (
// If there are dummy type arguments in typeFun part, it suggests we
// must type the actual constructor call, not only the select. The value
@@ -3486,13 +3489,11 @@ trait Typers extends Adaptations with Tags {
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
+ case (arg :: Nil) :: Nil if !isNamed(arg) => mkNamedArg(arg, nme.value) :: Nil
+ case args :: Nil => args
}
val nvPairs = args map {
diff --git a/test/files/neg/t5182.check b/test/files/neg/t5182.check
new file mode 100644
index 0000000000..3161f92680
--- /dev/null
+++ b/test/files/neg/t5182.check
@@ -0,0 +1,7 @@
+t5182.scala:2: error: unknown annotation argument name: qwe
+ @java.lang.Deprecated(qwe = "wer") def ok(q:Int) = 1
+ ^
+t5182.scala:3: error: classfile annotation arguments have to be supplied as named arguments
+ @java.lang.Deprecated("wer") def whereAmI(q:Int) = 1
+ ^
+two errors found
diff --git a/test/files/neg/t5182.flags b/test/files/neg/t5182.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/t5182.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/t5182.scala b/test/files/neg/t5182.scala
new file mode 100644
index 0000000000..0687e99efb
--- /dev/null
+++ b/test/files/neg/t5182.scala
@@ -0,0 +1,5 @@
+class test {
+ @java.lang.Deprecated(qwe = "wer") def ok(q:Int) = 1
+ @java.lang.Deprecated("wer") def whereAmI(q:Int) = 1
+ @java.lang.Deprecated() def bippy(q:Int) = 1
+}