new inference: choose most specifics between 2 varargs methods

(cherry picked from commit 9f754331ad04e4be639d94da7a659927f8384294)
This commit is contained in:
Anna Kozlova
2014-03-12 10:16:12 +01:00
parent 1ee2942d53
commit 4112118f42
3 changed files with 22 additions and 3 deletions
@@ -928,7 +928,7 @@ public class InferenceSession {
}
if (varargs) {
PsiType sType = siteSubstitutor2.substitute(parameters1[paramsLength].getType());
PsiType sType = siteSubstitutor2.substitute(getVarargParameterType(true, paramsLength, parameters1));
PsiType tType = siteSubstitutor2.substitute(getVarargParameterType(true, paramsLength, parameters2));
session.addConstraint(new StrictSubtypingConstraint(tType, sType));
}
@@ -939,8 +939,9 @@ public class InferenceSession {
public static PsiType getVarargParameterType(boolean varargs, int i, PsiParameter[] parameters2) {
if (varargs && i >= parameters2.length - 1) {
final PsiType lastParamType = parameters2[parameters2.length - 1].getType();
LOG.assertTrue(lastParamType instanceof PsiEllipsisType);
return ((PsiEllipsisType)lastParamType).getComponentType();
if (lastParamType instanceof PsiEllipsisType) {
return ((PsiEllipsisType)lastParamType).getComponentType();
}
}
return parameters2[i].getType();
}
@@ -0,0 +1,14 @@
import java.util.List;
abstract class StreamMain {
public abstract <T> Iterable<T> concat(final Iterable<? extends T>... iterables);
public abstract <T> Iterable<T> concat(final List<? extends T>... iterables);
public final List<String> errorFixesToShow = null;
public final List<String> inspectionFixesToShow = null;
{
concat(errorFixesToShow, inspectionFixesToShow);
}
}
@@ -43,6 +43,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
doTest();
}
public void testBothVarargs() throws Exception {
doTest();
}
private void doTest() {
doTest(true);
}