new inference: don't process expressions after param.length for non-varargs (IDEA-149489)

This commit is contained in:
Anna Kozlova
2015-12-28 14:54:04 +01:00
parent 6eb6846280
commit e4ef475f9e
3 changed files with 23 additions and 0 deletions

View File

@@ -156,6 +156,11 @@ public class InferenceSession {
}
if (parameters.length > 0) {
for (int i = 0; i < args.length; i++) {
//don't infer anything if number of parameters differ and method is not vararg
if (!varargs && i >= parameters.length) {
continue;
}
if (args[i] != null && isPertinentToApplicability(args[i], method)) {
PsiType parameterType = getParameterType(parameters, i, mySiteSubstitutor, varargs);
addConstraint(new ExpressionCompatibilityConstraint(args[i], substituteWithInferenceVariables(parameterType)));

View File

@@ -0,0 +1,9 @@
// "Add 'String' as 2nd parameter to method 'get'" "true"
import java.util.List;
class Test<T> {
public LazyVal(final List<T> ts) {
get(ts, "");
}
public static <T1> void get(List<T1> l, String s) {}
}

View File

@@ -0,0 +1,9 @@
// "Add 'String' as 2nd parameter to method 'get'" "true"
import java.util.List;
class Test<T> {
public LazyVal(final List<T> ts) {
get(t<caret>s, "");
}
public static <T1> void get(List<T1> l) {}
}