diff options
Diffstat (limited to 'sources/scalac/typechecker/Infer.java')
-rw-r--r-- | sources/scalac/typechecker/Infer.java | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/sources/scalac/typechecker/Infer.java b/sources/scalac/typechecker/Infer.java index c788a368da..9da7ef13d8 100644 --- a/sources/scalac/typechecker/Infer.java +++ b/sources/scalac/typechecker/Infer.java @@ -398,14 +398,17 @@ public class Infer implements Modifiers, Kinds { Type insttype = restype.subst(tparams, tvars); Type[] targs = new Type[tvars.length]; if (isCompatible(insttype, pt)) { - for (int i = 0; i < tvars.length; i++) { - targs[i] = instantiateUpper(tvars[i], isCovariant(tparams[i], params)); - } - } else { - for (int i = 0; i < tvars.length; i++) { - targs[i] = Type.AnyType; + try { + for (int i = 0; i < tvars.length; i++) { + targs[i] = instantiateUpper(tvars[i], isCovariant(tparams[i], params)); + } + return targs; + } catch (NoInstance ex) { } } + for (int i = 0; i < tvars.length; i++) { + targs[i] = Type.AnyType; + } return targs; } @@ -824,7 +827,7 @@ public class Infer implements Modifiers, Kinds { } if (i < alttypes.length) { for (int j = i + 1; j < alttypes.length; j++) { - if (alts[i].isValue() && alttypes[i].typeParams().length == nparams) + if (alts[j].isValue() && alttypes[j].typeParams().length == nparams) throw new Type.Error(overloadResolveErrorMsg( alts[i], alttypes[i], alts[j], alttypes[j])); } |