don't treat static method as concrete in hierarchy (IDEA-180930)

This commit is contained in:
Anna.Kozlova
2017-10-25 14:27:54 +02:00
parent c48690294f
commit c8f8341d2f
3 changed files with 26 additions and 2 deletions

View File

@@ -461,7 +461,7 @@ public class GenericsHighlightUtil {
if (abstracts == null) abstracts = new ArrayList<>(2);
abstracts.add(method);
}
hasConcrete |= !isDefault && !isAbstract;
hasConcrete |= !isDefault && !isAbstract && !method.hasModifierProperty(PsiModifier.STATIC);
}
if (!hasConcrete && defaults != null) {
@@ -469,7 +469,16 @@ public class GenericsHighlightUtil {
if (MethodSignatureUtil.findMethodBySuperMethod(aClass, defaultMethod, false) != null) continue;
final PsiClass defaultMethodContainingClass = defaultMethod.getContainingClass();
if (defaultMethodContainingClass == null) continue;
final PsiMethod unrelatedMethod = abstracts != null ? abstracts.get(0) : defaults.get(1);
final PsiMethod unrelatedMethod;
if (abstracts != null) {
unrelatedMethod = abstracts.get(0);
}
else if (defaults.size() > 1) {
unrelatedMethod = defaults.get(1);
}
else {
continue;
}
final PsiClass unrelatedMethodContainingClass = unrelatedMethod.getContainingClass();
if (unrelatedMethodContainingClass == null) continue;
if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT) && !(aClass instanceof PsiTypeParameter)

View File

@@ -0,0 +1,13 @@
interface A {
default void m() { }
}
interface B {
static void m() { }
}
interface C {
void m();
}
class <error descr="Class 'D' must either be declared abstract or implement abstract method 'm()' in 'C'">D</error> implements A, B, C { }

View File

@@ -128,6 +128,8 @@ public class Interface8MethodsHighlightingTest extends LightCodeInsightFixtureTe
doTest();
}
public void testStaticAbstractDefaultInOneHierarchy() { doTest(); }
public void testMethodHierarchyWithDeclaredTypeParameters() {
doTest();
}