mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Final field referenced from anonymous class argument list: continue search instead of return
Fixed: IDEA-208030 False positive Variable might not have been initialized
This commit is contained in:
+5
-5
@@ -420,21 +420,21 @@ public class HighlightControlFlowUtil {
|
||||
}
|
||||
|
||||
private static boolean inInnerClass(@NotNull PsiElement psiElement, @Nullable PsiClass containingClass) {
|
||||
PsiElement element = psiElement;
|
||||
while (element != null) {
|
||||
for (PsiElement element = psiElement;element != null;element = element.getParent()) {
|
||||
if (element instanceof PsiClass) {
|
||||
final boolean innerClass = !psiElement.getManager().areElementsEquivalent(element, containingClass);
|
||||
if (innerClass) {
|
||||
if (element instanceof PsiAnonymousClass) {
|
||||
return !(PsiTreeUtil.isAncestor(((PsiAnonymousClass)element).getArgumentList(), psiElement, false) ||
|
||||
insideClassInitialization(containingClass, (PsiClass)element));
|
||||
if (PsiTreeUtil.isAncestor(((PsiAnonymousClass)element).getArgumentList(), psiElement, false)) {
|
||||
continue;
|
||||
}
|
||||
return !insideClassInitialization(containingClass, (PsiClass)element);
|
||||
}
|
||||
final PsiLambdaExpression lambdaExpression = PsiTreeUtil.getParentOfType(psiElement, PsiLambdaExpression.class);
|
||||
return lambdaExpression == null || !insideClassInitialization(containingClass, (PsiClass)element);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
element = element.getParent();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import java.util.Date;
|
||||
|
||||
class C {
|
||||
private final String s;
|
||||
|
||||
C(String s) {
|
||||
this.s = s;
|
||||
}
|
||||
|
||||
Object m() {
|
||||
return new Object() {
|
||||
private final Date d = new Date(s) {}; // reference to s is legal
|
||||
};
|
||||
}
|
||||
}
|
||||
+1
@@ -121,6 +121,7 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testVarDoubleInitialization() { doTest(false); }
|
||||
public void testFieldDoubleInitialization() { doTest(false); }
|
||||
public void testFinalFieldInitialization() { doTest(false); }
|
||||
public void testFinalFieldUsedInAnonymousArgumentListInsideInner() { doTest(false); }
|
||||
public void testAssignToFinal() { doTest(false); }
|
||||
public void testUnhandledExceptionsInSuperclass() { doTest(false); }
|
||||
public void testNoUnhandledExceptionsMultipleInheritance() { doTest(false); }
|
||||
|
||||
Reference in New Issue
Block a user