mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
can be final: ensure non final for base of anonymous class (IDEA-118493)
This commit is contained in:
+4
-5
@@ -51,11 +51,7 @@ class CanBeFinalAnnotator extends RefGraphAnnotatorEx {
|
||||
((RefClassImpl)refClass).setFlag(false, CAN_BE_FINAL_MASK);
|
||||
return;
|
||||
}
|
||||
if (refClass.isAbstract() || refClass.isAnonymous() || refClass.isInterface()) {
|
||||
((RefClassImpl)refClass).setFlag(false, CAN_BE_FINAL_MASK);
|
||||
return;
|
||||
}
|
||||
if (!refClass.isSelfInheritor(psiClass)) {
|
||||
if (psiClass != null && !refClass.isSelfInheritor(psiClass)) {
|
||||
for (PsiClass psiSuperClass : psiClass.getSupers()) {
|
||||
if (myManager.belongsToScope(psiSuperClass)) {
|
||||
RefClass refSuperClass = (RefClass)myManager.getReference(psiSuperClass);
|
||||
@@ -65,6 +61,9 @@ class CanBeFinalAnnotator extends RefGraphAnnotatorEx {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (refClass.isAbstract() || refClass.isAnonymous() || refClass.isInterface()) {
|
||||
((RefClassImpl)refClass).setFlag(false, CAN_BE_FINAL_MASK);
|
||||
}
|
||||
}
|
||||
else if (refElement instanceof RefMethod) {
|
||||
final RefMethod refMethod = (RefMethod)refElement;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<problems/>
|
||||
@@ -0,0 +1,22 @@
|
||||
final class Test
|
||||
{
|
||||
public static class Foo
|
||||
{
|
||||
void fun()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Foo get()
|
||||
{
|
||||
return new Foo()
|
||||
{
|
||||
@Override
|
||||
void fun()
|
||||
{
|
||||
super.fun();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,10 @@ public class CanBeFinalTest extends InspectionTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testanonymous() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testmethodInheritance() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user