mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-94181 Boolean truth inference
This commit is contained in:
@@ -1094,15 +1094,13 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
PsiExpression operand = operands[i];
|
||||
operand.accept(this);
|
||||
generateBoxingUnboxingInstructionFor(operand, exprType);
|
||||
PsiExpression nextOperand = i == operands.length - 1 ? null : operands[i + 1];
|
||||
|
||||
if (nextOperand != null) {
|
||||
ConditionalGotoInstruction onFail = new ConditionalGotoInstruction(-1, true, operand);
|
||||
branchToFail.add(onFail);
|
||||
addInstruction(onFail);
|
||||
}
|
||||
ConditionalGotoInstruction onFail = new ConditionalGotoInstruction(-1, true, operand);
|
||||
branchToFail.add(onFail);
|
||||
addInstruction(onFail);
|
||||
}
|
||||
|
||||
addInstruction(new PushInstruction(myFactory.getConstFactory().getTrue(), null));
|
||||
GotoInstruction toSuccess = new GotoInstruction(-1);
|
||||
addInstruction(toSuccess);
|
||||
PushInstruction pushFalse = new PushInstruction(myFactory.getConstFactory().getFalse(), null);
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
class Fun {
|
||||
private void parseDeclarator(Object builder, boolean isTuple) {
|
||||
if (!isTuple) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
if (smth() && <warning descr="Condition 'isTuple' is always 'true' when reached">isTuple</warning>) {
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean smth() { return true; }
|
||||
}
|
||||
@@ -375,4 +375,13 @@
|
||||
<problem_class>Constant conditions & exceptions</problem_class>
|
||||
<description>Unboxing of <code>i</code> may produce <code>java.lang.NullPointerException</code>.</description>
|
||||
</problem>
|
||||
|
||||
<problem>
|
||||
<file>Test.java</file>
|
||||
<line>67</line>
|
||||
<package><default></package>
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Constant conditions & exceptions</problem_class>
|
||||
<description>Condition <code>i</code> is always <code>true</code> when reached</description>
|
||||
</problem>
|
||||
|
||||
</problems>
|
||||
|
||||
@@ -138,5 +138,6 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
|
||||
|
||||
public void testMethodCallFlushesField() { doTest(); }
|
||||
public void testUnknownFloatMayBeNaN() { doTest(); }
|
||||
public void testLastConstantConditionInAnd() { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user