mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
overload resolution: check method hiding for static only (IDEA-183712)
non-static methods should already be covered by same signatures check
This commit is contained in:
@@ -214,7 +214,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
final boolean isInterface = containingClass != null && containingClass.isInterface();
|
||||
for (HierarchicalMethodSignature methodSignature : method.getHierarchicalMethodSignature().getSuperSignatures()) {
|
||||
final PsiMethod superMethod = methodSignature.getMethod();
|
||||
PsiMethod superMethod = PsiSuperMethodUtil.correctMethodByScope(methodSignature.getMethod(), myArgumentsList.getResolveScope());
|
||||
if (!isInterface) {
|
||||
superMethods.add(superMethod);
|
||||
}
|
||||
@@ -587,7 +587,7 @@ public class JavaMethodsConflictResolver implements PsiConflictResolver{
|
||||
}
|
||||
}
|
||||
|
||||
if (class1 != class2) {
|
||||
if (class1 != class2 && (method1.hasModifierProperty(PsiModifier.STATIC) || method2.hasModifierProperty(PsiModifier.STATIC))) {
|
||||
if (class2.isInheritor(class1, true)) {
|
||||
if (MethodSignatureUtil.isSubsignature(method1.getSignature(classSubstitutor1), method2.getSignature(classSubstitutor2))) {
|
||||
return Specifics.SECOND;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
class X {
|
||||
void method(String t) { }
|
||||
}
|
||||
|
||||
class Y<S extends CharSequence> extends X {
|
||||
void method(S s) { }
|
||||
}
|
||||
|
||||
class Test {
|
||||
void x(final Y<String> err) {
|
||||
err.method<error descr="Ambiguous method call: both 'Y.method(String)' and 'X.method(String)' match">("")</error>;
|
||||
}
|
||||
}
|
||||
@@ -262,6 +262,8 @@ public class OverloadResolutionTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
public void testAdaptReturnTypesOfSiblingMethods() { doTest(false);}
|
||||
|
||||
public void testOverriddenMethodWithOtherRawSignature() { doTest(false);}
|
||||
|
||||
public void testUnqualifiedStaticInterfaceMethodCallsOnInnerClasses() { doTest(false);}
|
||||
|
||||
public void testStaticMethodInSuperInterfaceConflictWithCurrentStatic() { doTest(false);}
|
||||
|
||||
Reference in New Issue
Block a user