mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Error is reported when qualified this is used to initialize a final variable
Fixes IDEA-191686 Bad code is green (cannot assign a value to final variable)
This commit is contained in:
+2
-1
@@ -652,7 +652,8 @@ public class HighlightControlFlowUtil {
|
||||
|
||||
if (!containingFile.getManager().areElementsEquivalent(enclosingCtrOrInitializer.getContainingClass(), field.getContainingClass())) return false;
|
||||
PsiExpression qualifierExpression = reference.getQualifierExpression();
|
||||
return qualifierExpression == null || qualifierExpression instanceof PsiThisExpression;
|
||||
return qualifierExpression == null || (qualifierExpression instanceof PsiThisExpression &&
|
||||
((PsiThisExpression)qualifierExpression).getQualifier() == null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+9
@@ -243,3 +243,12 @@ class AssignmentInUnreachablePolyadic {
|
||||
else if (true && (<error descr="Variable 'bbbb' might already have been assigned to">bbbb</error> = false)) ;
|
||||
}
|
||||
}
|
||||
|
||||
class QualifiedThis {
|
||||
final int x;
|
||||
|
||||
QualifiedThis() {
|
||||
<error descr="Cannot assign a value to final variable 'x'">QualifiedThis.this.x</error> = 5;
|
||||
<error descr="Variable 'x' might already have been assigned to">this.x</error> = 5;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user