mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
overload resolution: reject methods with wrong number of parameters even if vararg method is present (IDEA-131093)
This commit is contained in:
@@ -329,8 +329,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
if (ignoreIfStaticsProblem && !info.isStaticsScopeCorrect()) return true;
|
||||
if (!(info instanceof MethodCandidateInfo)) continue;
|
||||
PsiMethod method = ((MethodCandidateInfo)info).getElement();
|
||||
if (method.isVarArgs()) return true;
|
||||
if (method.getParameterList().getParametersCount() == argumentsCount) {
|
||||
if (method.isVarArgs() || method.getParameterList().getParametersCount() == argumentsCount) {
|
||||
// remove all unmatched before
|
||||
if (unmatchedIndices != null) {
|
||||
for (int u=unmatchedIndices.size()-1; u>=0; u--) {
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
class Test {
|
||||
{
|
||||
ImmutableList.of(
|
||||
Pair.of(' ', ImmutableMap.of()),
|
||||
Pair.of(',', ImmutableMap.of()),
|
||||
Pair.of('<', ImmutableMap.of()),
|
||||
Pair.of('>', ImmutableMap.of()),
|
||||
Pair.of('/', ImmutableMap.of("streetVanity", "/")),
|
||||
Pair.of('?', ImmutableMap.of()),
|
||||
Pair.of(';', ImmutableMap.of("streetVanity", ",")),
|
||||
Pair.of(':', ImmutableMap.of()),
|
||||
Pair.of('\\', ImmutableMap.of()),
|
||||
Pair.of('|', ImmutableMap.of()),
|
||||
Pair.of('-', ImmutableMap.of()),
|
||||
Pair.of('_', ImmutableMap.of()),
|
||||
Pair.of('!', ImmutableMap.of()),
|
||||
Pair.of('@', ImmutableMap.of()),
|
||||
Pair.of('#', ImmutableMap.of())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Pair<A, B> {
|
||||
public static <C, D> Pair<C, D> of(C c, D d) {return null;}
|
||||
}
|
||||
|
||||
class ImmutableList<S> {
|
||||
public static <E> ImmutableList<E> of() {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12) {return null;}
|
||||
public static <E> ImmutableList<E> of(E e1, E e2, E e3, E e4, E e5, E e6, E e7, E e8, E e9, E e10, E e11, E e12, E... o) {return null;}
|
||||
}
|
||||
|
||||
class ImmutableMap<T, S> {
|
||||
public static <E, K> ImmutableMap<E, K> of() {return null;}
|
||||
public static <E, K> ImmutableMap<E, K> of(E e1, K k1) {return null;}
|
||||
public static <E, K> ImmutableMap<E, K> of(E e1, K k1, E e2, K k2) {return null;}
|
||||
public static <E, K> ImmutableMap<E, K> of(E e1, K k1, E e2, K k2, E e3, K k3) {return null;}
|
||||
public static <E, K> ImmutableMap<E, K> of(E e1, K k1, E e2, K k2, E e3, K k3, E e4, K k4) {return null;}
|
||||
public static <E, K> ImmutableMap<E, K> of(E e1, K k1, E e2, K k2, E e3, K k3, E e4, K k4, E e5, K k5) {return null;}
|
||||
public static <E, K> ImmutableMap<E, K> of(E e1, K k1, E e2, K k2, E e3, K k3, E e4, K k4, E e5, K k5, E e6, K k6) {return null;}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import com.intellij.codeInspection.deadCode.UnusedDeclarationInspection;
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
@@ -87,6 +89,15 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testManyOverloadsWithVarargs() throws Exception {
|
||||
PlatformTestUtil.startPerformanceTest("Overload resolution with 14 overloads", 20000, new ThrowableRunnable() {
|
||||
@Override
|
||||
public void run() throws Throwable {
|
||||
doTest(false);
|
||||
}
|
||||
}).assertTiming();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user