mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-21 14:37:45 +07:00
FinalUtils#canBeFinal: field assignments are checked within top-level class
Fixes IDEA-187493 False "Field may be final" inspection
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ public class FinalUtils {
|
||||
return false;
|
||||
}
|
||||
PsiElement scope = variable instanceof PsiField
|
||||
? ((PsiField)variable).getContainingClass()
|
||||
? PsiUtil.getTopLevelClass(variable)
|
||||
: PsiUtil.getVariableCodeBlock(variable, null);
|
||||
if (scope == null) return false;
|
||||
Map<PsiElement, Collection<ControlFlowUtil.VariableInfo>> finalVarProblems = new THashMap<>();
|
||||
|
||||
+12
@@ -1071,4 +1071,16 @@ class T74 {
|
||||
x = 2;
|
||||
}
|
||||
int y = x = 3;
|
||||
}
|
||||
// IDEA-187493
|
||||
class T75 {
|
||||
void foo() {
|
||||
new Inner().innerField = 1;
|
||||
}
|
||||
|
||||
private static class Inner {
|
||||
private int innerField;
|
||||
|
||||
private Inner() {innerField = 0;}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user