mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 13:31:28 +07:00
generics: from same signature methods prefer methods without wildcards (IDEA-90802)
This commit is contained in:
@@ -282,9 +282,15 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
}
|
||||
|
||||
if (currentClass != null && InheritanceUtil.isInheritorOrSelf(currentClass, class1, true) && InheritanceUtil.isInheritorOrSelf(currentClass, existingClass, true)) {
|
||||
if (MethodSignatureUtil.areSignaturesEqual(existingMethod.getSignature(TypeConversionUtil.getSuperClassSubstitutor(existingClass, currentClass, PsiSubstitutor.EMPTY)),
|
||||
method.getSignature(TypeConversionUtil.getSuperClassSubstitutor(class1, currentClass, PsiSubstitutor.EMPTY)))) {
|
||||
conflicts.remove(i);
|
||||
final PsiSubstitutor eSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(existingClass, currentClass, PsiSubstitutor.EMPTY);
|
||||
final PsiSubstitutor cSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(class1, currentClass, PsiSubstitutor.EMPTY);
|
||||
if (MethodSignatureUtil.areSignaturesEqual(existingMethod.getSignature(eSubstitutor), method.getSignature(cSubstitutor))) {
|
||||
final PsiType returnType = cSubstitutor.substitute(method.getReturnType());
|
||||
if (PsiUtil.captureToplevelWildcards(returnType, method).equals(returnType)) {
|
||||
conflicts.remove(existing);
|
||||
} else {
|
||||
conflicts.remove(i);
|
||||
}
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import java.util.*;
|
||||
|
||||
interface VcsRoot {
|
||||
}
|
||||
|
||||
interface SVcsRoot extends VcsRoot {
|
||||
}
|
||||
|
||||
interface A {
|
||||
List<? extends VcsRoot> getVcsRoots();
|
||||
}
|
||||
|
||||
interface B {
|
||||
List<SVcsRoot> getVcsRoots();
|
||||
}
|
||||
|
||||
interface F1 extends A, B {
|
||||
}
|
||||
|
||||
class G {
|
||||
void f(F1 o) {
|
||||
SVcsRoot r = o.getVcsRoots().get(0);
|
||||
}
|
||||
}
|
||||
@@ -180,6 +180,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA57310() throws Exception { doTest(false); }
|
||||
public void testIDEA57311() throws Exception { doTest(false); }
|
||||
public void testIDEA57309() throws Exception { doTest(false); }
|
||||
public void testIDEA90802() throws Exception { doTest(false); }
|
||||
public void testInconvertibleTypes() throws Exception { doTest(false); }
|
||||
public void testIncompatibleReturnType() throws Exception { doTest(false); }
|
||||
public void testContinueInferenceAfterFirstRawResult() throws Exception { doTest(false); }
|
||||
|
||||
Reference in New Issue
Block a user