summaryrefslogtreecommitdiff
path: root/sources/scalac/typechecker/Infer.java
diff options
context:
space:
mode:
Diffstat (limited to 'sources/scalac/typechecker/Infer.java')
-rw-r--r--sources/scalac/typechecker/Infer.java21
1 files changed, 15 insertions, 6 deletions
diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java
index ea6cb4ddc4..b2b38ef2da 100644
--- a/sources/scalac/typechecker/Infer.java
+++ b/sources/scalac/typechecker/Infer.java
@@ -333,15 +333,24 @@ public class Infer implements Modifiers, Kinds {
* If `params' is a repeated parameter, a list of `length' copies
* of its type is returned.
*/
- public Type[] formalTypes(Symbol[] params, int length) {
+ public Type[] formalTypes(Symbol[] params, int nargs) {
Type[] result;
- if (params.length == 1 && (params[0].flags & REPEATED) != 0) {
- Type[] formals = new Type[length];
- Type[] args = params[0].type().typeArgs();
+ if (params.length > 0 &&
+ (params[params.length-1].flags & REPEATED) != 0) {
+ Type[] args = params[params.length-1].type().typeArgs();
if (args.length == 1) {
Type ft = args[0];
- // params[0] has type Seq[T], we need T here
- for (int i = 0; i < length; i++) formals[i] = ft;
+ // last param has type Seq[T], we need T here
+ Type[] formals = new Type[nargs];
+ int i = 0;
+ while (i < params.length-1) {
+ formals[i] = params[i].type();
+ i++;
+ }
+ while (i < nargs) {
+ formals[i] = ft;
+ i++;
+ }
return formals;
}
}