diff options
author | Paul Phillips <paulp@improving.org> | 2013-01-14 23:29:50 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-01-26 11:19:36 -0800 |
commit | 801eab55019c433d2fa6a925d02e41b1c47cbf22 (patch) | |
tree | 2b7d5351cb87a9b20a02b3f09ea05c00e8c88dbc | |
parent | 832fc9a67e5aa85bdde61883527d3ac9554094d7 (diff) | |
download | scala-801eab55019c433d2fa6a925d02e41b1c47cbf22.tar.gz scala-801eab55019c433d2fa6a925d02e41b1c47cbf22.tar.bz2 scala-801eab55019c433d2fa6a925d02e41b1c47cbf22.zip |
SI-5182, no position on annotation error.
Now there's a position on the synthetic "value" Ident.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 13 | ||||
-rw-r--r-- | test/files/neg/t5182.check | 7 | ||||
-rw-r--r-- | test/files/neg/t5182.flags | 1 | ||||
-rw-r--r-- | test/files/neg/t5182.scala | 5 |
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 +} |