mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 05:21:29 +07:00
Java control flow: Handle the case where the variable from the left part of a compound assignment is modified in the right part of the same assignment (IDEA-23725)
This commit is contained in:
@@ -1307,9 +1307,6 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
|
||||
PsiExpression lExpr = PsiUtil.skipParenthesizedExprDown(expression.getLExpression());
|
||||
if (lExpr instanceof PsiReferenceExpression) {
|
||||
if (rExpr != null) {
|
||||
rExpr.accept(this);
|
||||
}
|
||||
PsiVariable variable = getUsedVariable((PsiReferenceExpression)lExpr);
|
||||
if (variable != null) {
|
||||
if (myAssignmentTargetsAreElements) {
|
||||
@@ -1324,11 +1321,17 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
if (expression.getOperationTokenType() != JavaTokenType.EQ) {
|
||||
generateReadInstruction(variable);
|
||||
}
|
||||
if (rExpr != null) {
|
||||
rExpr.accept(this);
|
||||
}
|
||||
generateWriteInstruction(variable);
|
||||
|
||||
if (myAssignmentTargetsAreElements) finishElement(lExpr);
|
||||
}
|
||||
else {
|
||||
if (rExpr != null) {
|
||||
rExpr.accept(this);
|
||||
}
|
||||
lExpr.accept(this); //?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,4 +444,12 @@ class AssignInAssert {
|
||||
if(<error descr="Variable 'a' might not have been initialized">a</error>)
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
class CompoundAssign {
|
||||
void f() {
|
||||
int i;
|
||||
<error descr="Variable 'i' might not have been initialized">i</error> += i = 2;
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user