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:
Anna.Kozlova
2017-12-13 13:44:11 +01:00
parent 14a9d09035
commit 1d6641db80
3 changed files with 17 additions and 2 deletions

View File

@@ -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;

View File

@@ -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>;
}
}

View File

@@ -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);}