mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
warn about usages of final fields in another fields even if they appear after constructor where it would be definitely assigned (IDEA-114280)
This commit is contained in:
@@ -252,7 +252,7 @@ public class HighlightControlFlowUtil {
|
||||
Map<PsiElement, Collection<PsiReferenceExpression>> uninitializedVarProblems, @NotNull PsiFile containingFile) {
|
||||
if (variable instanceof ImplicitVariable) return null;
|
||||
if (!PsiUtil.isAccessedForReading(expression)) return null;
|
||||
final int startOffset = expression.getTextRange().getStartOffset();
|
||||
int startOffset = expression.getTextRange().getStartOffset();
|
||||
final PsiElement topBlock;
|
||||
if (variable.hasInitializer()) {
|
||||
topBlock = PsiUtil.getVariableCodeBlock(variable, variable);
|
||||
@@ -317,6 +317,10 @@ public class HighlightControlFlowUtil {
|
||||
if (aClass == null || isFieldInitializedInOtherFieldInitializer(aClass, field, field.hasModifierProperty(PsiModifier.STATIC))) {
|
||||
return null;
|
||||
}
|
||||
final PsiField anotherField = PsiTreeUtil.getParentOfType(expression, PsiField.class);
|
||||
if (anotherField != null && anotherField.getContainingClass() == aClass) {
|
||||
startOffset = 0;
|
||||
}
|
||||
block = null;
|
||||
// initializers will be checked later
|
||||
final PsiMethod[] constructors = aClass.getConstructors();
|
||||
|
||||
@@ -133,8 +133,8 @@ class c2 {
|
||||
public c2() {
|
||||
c = "";
|
||||
}
|
||||
// its ok
|
||||
int k3 = c.length();
|
||||
|
||||
int k3 = <error descr="Variable 'c' might not have been initialized">c</error>.length();
|
||||
|
||||
c2(int i) {
|
||||
this();
|
||||
|
||||
Reference in New Issue
Block a user