mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
overload resolution: ensure all list of parameters is checked during most specific check of varargs methods (IDEA-150224)
This commit is contained in:
@@ -1506,7 +1506,7 @@ public class InferenceSession {
|
||||
LOG.assertTrue(parameters1.length == parameters2.length);
|
||||
}
|
||||
|
||||
final int paramsLength = !varargs ? parameters1.length : parameters1.length - 1;
|
||||
final int paramsLength = !varargs ? parameters1.length : Math.max(parameters1.length, parameters2.length) - 1;
|
||||
for (int i = 0; i < paramsLength; i++) {
|
||||
PsiType sType = getParameterType(parameters1, i, siteSubstitutor1, false);
|
||||
PsiType tType = session.substituteWithInferenceVariables(getParameterType(parameters2, i, siteSubstitutor1, varargs));
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
interface Node<<warning descr="Type parameter 'T' is never used">T</warning>> {
|
||||
|
||||
@SafeVarargs
|
||||
static <T> Node<T> of(T value, Node<T>... children) {
|
||||
System.out.println(value);
|
||||
System.out.println(children);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@SafeVarargs
|
||||
static <T1> Node<T1> of(T1... values) {
|
||||
System.out.println(values);
|
||||
return null;
|
||||
}
|
||||
|
||||
static void test() {
|
||||
Node.of(1, Node.of(2), Node.of(3));
|
||||
Node.<Integer>of(1, Node.<Integer>of(2), Node.<Integer> of(3));
|
||||
}
|
||||
}
|
||||
@@ -195,6 +195,10 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testLongerParamsWhenVarargs() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user