mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ControlFlowAnalyzer: do not exclude polyadic operands after always true/false operand
Fixes IDEA-190766 Final field reassignment problems in always true/always false polyadic chains Review ID: IDEA-CR-29499
This commit is contained in:
@@ -1408,6 +1408,8 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
if (exprValue instanceof Boolean) {
|
||||
myCurrentFlow.setConstantConditionOccurred(true);
|
||||
rValue = shouldCalculateConstantExpression(expression) ? (Boolean)exprValue : null;
|
||||
} else {
|
||||
rValue = null;
|
||||
}
|
||||
|
||||
BranchingInstruction.Role role = isAndAnd ? myEndJumpRoles.peek() : myStartJumpRoles.peek();
|
||||
@@ -1436,13 +1438,12 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
if (lOperand != null) {
|
||||
myCurrentFlow.addInstruction(new GoToInstruction(0, role));
|
||||
addElementOffsetLater(gotoElement, gotoIsAtStart);
|
||||
rValue = null;
|
||||
}
|
||||
break;
|
||||
case SKIP_CURRENT_OPERAND:
|
||||
break;
|
||||
}
|
||||
|
||||
if (shortcut == Shortcut.STOP_EXPRESSION) break;
|
||||
}
|
||||
generateLOperand(rOperand, i == operands.length - 1 ? null : operands[i + 1], signTokenType);
|
||||
|
||||
|
||||
+27
@@ -216,3 +216,30 @@ class IncrementInUnreachableBranch {
|
||||
}
|
||||
}
|
||||
}
|
||||
class AssignmentInUnreachablePolyadic {
|
||||
private final boolean b;
|
||||
{
|
||||
if (false && (b = false)) ;
|
||||
if (true && (<error descr="Variable 'b' might already have been assigned to">b</error> = false)) ;
|
||||
}
|
||||
|
||||
<error descr="Variable 'bb' might not have been initialized">private final boolean bb</error>;
|
||||
{
|
||||
if (false && (bb = false) && (<error descr="Variable 'bb' might already have been assigned to">bb</error> = true)) ;
|
||||
}
|
||||
|
||||
private final boolean bbb;
|
||||
{
|
||||
if (false && (bbb = true)) {
|
||||
|
||||
} else {
|
||||
<error descr="Variable 'bbb' might already have been assigned to">bbb</error> = false;
|
||||
}
|
||||
}
|
||||
|
||||
private final boolean bbbb;
|
||||
{
|
||||
if (false && (bbbb = false) && (bbbb = true)) ;
|
||||
else if (true && (<error descr="Variable 'bbbb' might already have been assigned to">bbbb</error> = false)) ;
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -850,7 +850,7 @@ class T49 {
|
||||
}
|
||||
}
|
||||
class T50 {
|
||||
private boolean <warning descr="Field 'b' may be 'final'">b</warning>; // may be final
|
||||
private boolean b; // may not be final
|
||||
T50(int i) {
|
||||
if (false && (b = true)) {
|
||||
|
||||
@@ -902,7 +902,7 @@ class T55 {
|
||||
}
|
||||
}
|
||||
class T56 {
|
||||
private boolean <warning descr="Field 'b' may be 'final'">b</warning>; // may be final
|
||||
private boolean b; // may not be final
|
||||
{
|
||||
if (false && (b = false)) ;
|
||||
if (true && (b = false)) ;
|
||||
|
||||
Reference in New Issue
Block a user