diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-04-04 14:49:08 +0200 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-04-13 19:08:08 +0200 |
commit | e29681b95a215e8edf9e0f272d2a76aadac14fff (patch) | |
tree | d9062e9499e226a5af0f44614ace3d5ea6c8e96f /src | |
parent | 2286d7b43180f3018a041163dc0cfa951c0397a4 (diff) | |
download | scala-e29681b95a215e8edf9e0f272d2a76aadac14fff.tar.gz scala-e29681b95a215e8edf9e0f272d2a76aadac14fff.tar.bz2 scala-e29681b95a215e8edf9e0f272d2a76aadac14fff.zip |
rule out sequence arg to applyDynamic
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 18 |
2 files changed, 16 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala index edc69be827..38fbcf4ef4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/ContextErrors.scala @@ -504,6 +504,9 @@ trait ContextErrors { def ApplyWithoutArgsError(tree: Tree, fun: Tree) = NormalTypeError(tree, fun.tpe+" does not take parameters") + def DynamicVarArgUnsupported(tree: Tree, name: String) = + issueNormalTypeError(tree, name+ " does not support passing a vararg parameter") + //checkClassType def TypeNotAStablePrefixError(tpt: Tree, pre: Type) = { issueNormalTypeError(tpt, "type "+pre+" is not a stable prefix") diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 305e30aeee..0da118403d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3517,15 +3517,23 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { case t => (t, Nil) } + @inline def hasNamedArg(as: List[Tree]) = as collectFirst {case AssignOrNamedArg(lhs, rhs) =>} nonEmpty + // note: context.tree includes at most one Apply node // thus, we can't use it to detect we're going to receive named args in expressions such as: // qual.sel(a)(a2, arg2 = "a2") val oper = outer match { - case Apply(`tree`, as) => if (as collectFirst {case AssignOrNamedArg(lhs, rhs) =>} nonEmpty) - nme.applyDynamicNamed - else nme.applyDynamic - case Assign(`tree`, _) => nme.updateDynamic - case _ => nme.selectDynamic + case Apply(`tree`, as) => + val oper = + if (hasNamedArg(as)) nme.applyDynamicNamed + else nme.applyDynamic + // not supported: foo.bar(a1,..., an: _*) + if (treeInfo.isWildcardStarArgList(as)) { + DynamicVarArgUnsupported(tree, oper) + return Some(setError(tree)) + } else oper + case Assign(`tree`, _) => nme.updateDynamic + case _ => nme.selectDynamic } val dynSel = Select(qual, oper) |