mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new inference: choose most specifics between 2 varargs methods
(cherry picked from commit 9f754331ad04e4be639d94da7a659927f8384294)
This commit is contained in:
+4
-3
@@ -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();
|
||||
}
|
||||
|
||||
+14
@@ -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);
|
||||
}
|
||||
}
|
||||
+4
@@ -43,6 +43,10 @@ public class MostSpecificResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testBothVarargs() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user