overload conflicts: assume that subsignature conflicts are already resolved when most specific are checked (IDEA-168894)

This commit is contained in:
Anna.Kozlova
2017-03-06 09:45:46 +01:00
parent f34a8eaf3c
commit effcbfe27b
3 changed files with 32 additions and 3 deletions

View File

@@ -20,7 +20,6 @@ import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.projectRoots.JavaSdkVersion;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.*;
import com.intellij.psi.impl.PsiSuperMethodImplUtil;
@@ -679,12 +678,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
}
if (class1 != class2) {
if (class2.isInheritor(class1, true) || class1.isInterface() && !class2.isInterface()) {
if (class2.isInheritor(class1, true)) {
if (isSubSignature(method1, method2, classSubstitutor1, classSubstitutor2, boxingHappened)) {
return Specifics.SECOND;
}
}
else if (class1.isInheritor(class2, true) || class2.isInterface()) {
else if (class1.isInheritor(class2, true)) {
if (isSubSignature(method2, method1, classSubstitutor2, classSubstitutor1, boxingHappened)) {
return Specifics.FIRST;
}

View File

@@ -0,0 +1,11 @@
package p;
import static p.A.of;
import static p.B.of;
class Test {
{
of(1, 2, 3);
of<error descr="Ambiguous method call: both 'A.of(Integer)' and 'B.of(Integer)' match">(4)</error>;
}
}

View File

@@ -112,6 +112,25 @@ public class LightAdvHighlightingFixtureTest extends LightCodeInsightFixtureTest
myFixture.checkHighlighting();
}
public void testAmbiguousMethodCallWhenStaticImported() throws Exception {
myFixture.addClass("package p;" +
"class A<K> {\n" +
" static <T> A<T> of(T t) {\n" +
" return null;\n" +
" }\n" +
"}\n" +
"class B<K> {\n" +
" static <T> B<T> of(T t) {\n" +
" return null;\n" +
" }\n" +
" static <T> B<T> of(T... t) {\n" +
" return null;\n" +
" }\n" +
"}\n");
myFixture.configureByFile(getTestName(false) + ".java");
myFixture.checkHighlighting();
}
@Override
protected String getBasePath() {
return JavaTestUtil.getRelativeJavaTestDataPath() + "/codeInsight/daemonCodeAnalyzer/advFixture";