diff options
author | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-08-05 20:17:38 +0000 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@epfl.ch> | 2010-08-05 20:17:38 +0000 |
commit | 20efb133c53be74160d711286a99d3cd6d751fdf (patch) | |
tree | 912d89829ac43b8f5af7d055ff8c1ddb1cb5d15c /src/compiler/scala/tools/nsc/typechecker/Infer.scala | |
parent | 0a787b6477311a718cbb6abec15df9dfdc12186e (diff) | |
download | scala-20efb133c53be74160d711286a99d3cd6d751fdf.tar.gz scala-20efb133c53be74160d711286a99d3cd6d751fdf.tar.bz2 scala-20efb133c53be74160d711286a99d3cd6d751fdf.zip |
fixes names/defaults when using :_* for specify...
fixes names/defaults when using :_* for specifying repeated parameters.
close #3697, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Infer.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index 71c4353834..081f0053ec 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -40,19 +40,15 @@ trait Infer { * (nargs - params.length + 1) copies of its type is returned. * By-name types are replaced with their underlying type. * - * @param formals ... - * @param nargs ... + * @param removeByName allows keeping ByName parameters. Used in NamesDefaults. + * @param removeRepeated allows keeping repeated parameter (if there's one argument). Used in NamesDefaults. */ - def formalTypes(formals: List[Type], nargs: Int): List[Type] = - formalTypes(formals, nargs, true) - - /** This variant allows keeping ByName parameters. Useed in NamesDefaults. */ - def formalTypes(formals: List[Type], nargs: Int, removeByName: Boolean): List[Type] = { + def formalTypes(formals: List[Type], nargs: Int, removeByName: Boolean = true, removeRepeated: Boolean = true): List[Type] = { val formals1 = if (removeByName) formals mapConserve { case TypeRef(_, sym, List(arg)) if (sym == ByNameParamClass) => arg case formal => formal } else formals - if (isVarArgTpes(formals1)) { + if (isVarArgTpes(formals1) && (removeRepeated || formals.length != nargs)) { val ft = formals1.last.normalize.typeArgs.head formals1.init ::: (for (i <- List.range(formals1.length - 1, nargs)) yield ft) } else formals1 |