mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-13 09:19:13 +07:00
check for abstract method implemented optimized: don't go through hierarchy if superClass is not abstract and there is no interfaces, would also fix asm implementations with 'broken' erasures inside
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
package com.intellij.codeInsight;
|
||||
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -46,6 +47,10 @@ public class ClassUtil {
|
||||
|
||||
@Nullable
|
||||
public static PsiMethod getAnyMethodToImplement(@NotNull PsiClass aClass) {
|
||||
final PsiClass superClass = aClass instanceof PsiAnonymousClass ? PsiUtil.resolveClassInClassTypeOnly(((PsiAnonymousClass)aClass).getBaseClassType()) : aClass.getSuperClass();
|
||||
if (superClass != null && !superClass.hasModifierProperty(PsiModifier.ABSTRACT) && aClass.getImplementsListTypes().length == 0) {
|
||||
return null;
|
||||
}
|
||||
Set<PsiMethod> alreadyImplemented = new THashSet<PsiMethod>();
|
||||
for (HierarchicalMethodSignature signatureHierarchical : aClass.getVisibleSignatures()) {
|
||||
for (PsiMethod superS : signatureHierarchical.getMethod().findSuperMethods()) {
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
interface I {
|
||||
void m();
|
||||
}
|
||||
|
||||
<error descr="Class 'A' must either be declared abstract or implement abstract method 'm()' in 'I'">class A implements I</error> {}
|
||||
|
||||
class B extends A {}
|
||||
|
||||
class U {
|
||||
{
|
||||
new B() {};
|
||||
B b = new B();
|
||||
}
|
||||
}
|
||||
+3
@@ -69,4 +69,7 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testUnhandledErrorsFromEnumConstructors() {
|
||||
doTest(true, false);
|
||||
}
|
||||
public void testSkipAbstractMethodsIfTheyMustBeDeclaredInNonAbstractSuperclass() {
|
||||
doTest(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user