mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
overload resolution: static methods from super interfaces should be skipped in favor to instance methods (IDEA-216009)
GitOrigin-RevId: f172ea91498434cd956010df286dc418334a83b9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e5aabb8ae1
commit
67d165e584
@@ -60,6 +60,9 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
if (conflicts.isEmpty()) return null;
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
checkStaticMethodsOfInterfaces(conflicts);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
final Map<MethodCandidateInfo, PsiSubstitutor> map = FactoryMap.create(key -> key.getSubstitutor(false));
|
||||
boolean atLeastOneMatch = checkParametersNumber(conflicts, getActualParametersLength(), map, true);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
@@ -73,9 +76,6 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
checkParametersNumber(conflicts, getActualParametersLength(), map, false);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
checkStaticMethodsOfInterfaces(conflicts);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
|
||||
if (atLeastOneMatch) {
|
||||
checkPotentiallyCompatibleMethods(conflicts);
|
||||
if (conflicts.size() == 1) return conflicts.get(0);
|
||||
@@ -303,8 +303,12 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
}
|
||||
else if (expression == null && !ImportsUtil.hasStaticImportOn(parent, method, true)) {
|
||||
PsiClass qualifierClass = PsiTreeUtil.getParentOfType(parent, PsiClass.class);
|
||||
if (qualifierClass != null && !PsiTreeUtil.isAncestor(method.getContainingClass(), qualifierClass, true)) {
|
||||
return qualifierClass;
|
||||
if (qualifierClass != null) {
|
||||
PsiClass containingClass = method.getContainingClass();
|
||||
if (!PsiTreeUtil.isAncestor(containingClass, qualifierClass, true) ||
|
||||
qualifierClass.isInheritor(containingClass, true)) {
|
||||
return qualifierClass;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
interface ToStringBug {
|
||||
|
||||
static void toString(String s) {}
|
||||
|
||||
class Inner implements ToStringBug {
|
||||
|
||||
{
|
||||
toString<error descr="'toString()' in 'java.lang.Object' cannot be applied to '(java.lang.String)'">( "x")</error>;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,6 +276,7 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testUnqualifiedStaticInterfaceMethodCallsOnInnerClasses() { doTest(false);}
|
||||
|
||||
public void testStaticMethodInSuperInterfaceConflictWithCurrentStatic() { doTest(false);}
|
||||
public void testPreferMethodInsideSameComb() { doTest(false);}
|
||||
public void testFixedContainingClassTypeArguments() { doTest(false);}
|
||||
public void testPotentialCompatibilityWithArrayCreation() { doTest(false);}
|
||||
public void testOverloadsWithOneNonCompatible() { doTest(false);}
|
||||
|
||||
Reference in New Issue
Block a user