mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
[java-highlighting] Do not show error on override if there's an unresolved superclass
GitOrigin-RevId: 03bd2f1e2a303f8a36ac33c81ad9ccd64c3b5084
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e8b723c468
commit
8ee089b9b2
@@ -1122,13 +1122,22 @@ public final class GenericsHighlightUtil {
|
||||
}
|
||||
try {
|
||||
MethodSignatureBackedByPsiMethod superMethod = SuperMethodsSearch.search(method, null, true, false).findFirst();
|
||||
if (superMethod != null && method.getContainingClass().isInterface()) {
|
||||
PsiMethod psiMethod = superMethod.getMethod();
|
||||
PsiClass containingClass = psiMethod.getContainingClass();
|
||||
if (containingClass != null &&
|
||||
CommonClassNames.JAVA_LANG_OBJECT.equals(containingClass.getQualifiedName()) &&
|
||||
psiMethod.hasModifierProperty(PsiModifier.PROTECTED)) {
|
||||
superMethod = null;
|
||||
PsiClass psiClass = method.getContainingClass();
|
||||
if (psiClass != null) {
|
||||
if (superMethod != null && psiClass.isInterface()) {
|
||||
PsiMethod psiMethod = superMethod.getMethod();
|
||||
PsiClass superClass = psiMethod.getContainingClass();
|
||||
if (superClass != null &&
|
||||
CommonClassNames.JAVA_LANG_OBJECT.equals(superClass.getQualifiedName()) &&
|
||||
psiMethod.hasModifierProperty(PsiModifier.PROTECTED)) {
|
||||
superMethod = null;
|
||||
}
|
||||
} else if (superMethod == null) {
|
||||
for (PsiClassType type : psiClass.getSuperTypes()) {
|
||||
// There's an unresolvable superclass: likely the error on @Override is induced.
|
||||
// Do not show an error on override, as it's reasonable to fix hierarchy first.
|
||||
if (type.resolve() == null) return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (superMethod == null) {
|
||||
|
||||
@@ -11,3 +11,18 @@ class C implements I {
|
||||
|
||||
}
|
||||
}
|
||||
class Test extends <error descr="Cannot resolve symbol 'NonExisting'">NonExisting</error> {
|
||||
@Override
|
||||
void foo() {}
|
||||
}
|
||||
class Test1 implements <error descr="Cannot resolve symbol 'NonExistingIface'">NonExistingIface</error> {
|
||||
@Override
|
||||
void foo() {}
|
||||
}
|
||||
class Test2 extends Test {
|
||||
@Override
|
||||
void foo() {}
|
||||
|
||||
<error descr="Method does not override method from its superclass">@Override</error>
|
||||
void foo2() {}
|
||||
}
|
||||
Reference in New Issue
Block a user