dfa: method can still return unknown value if its arguments satisfy nullity conditions (IDEA-106205)

This commit is contained in:
peter
2013-05-06 19:07:56 +02:00
parent e6665d77c1
commit 61fcaa5361
2 changed files with 18 additions and 0 deletions
@@ -1347,6 +1347,17 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
} else if (type == ConditionChecker.Type.IS_NULL_METHOD || type == ConditionChecker.Type.IS_NOT_NULL_METHOD) {
addInstruction(new PushInstruction(myFactory.getConstFactory().getNull(), null));
addInstruction(new BinopInstruction(type == ConditionChecker.Type.IS_NULL_METHOD ? JavaTokenType.EQEQ : JavaTokenType.NE, null, expression.getProject()));
ConditionalGotoInstruction ifFails = new ConditionalGotoInstruction(-1, true, null);
GotoInstruction gotoEnd = new GotoInstruction(exitPoint);
addInstruction(ifFails);
pushUnknown();
addInstruction(gotoEnd);
ifFails.setOffset(myCurrentFlow.getInstructionCount());
addInstruction(new PushInstruction(myFactory.getConstFactory().getFalse(), null));
gotoEnd.setOffset(myCurrentFlow.getInstructionCount());
} else { //assertTrue or assertFalse
conditionalExit(exitPoint, type == ConditionChecker.Type.ASSERT_FALSE_METHOD);
}
@@ -4,6 +4,13 @@ public class IsNotNullCheck {
if (Value.isNotNull(v)) {
if(<warning descr="Condition 'v == null' is always 'false'">v == null</warning>) {}
}
}
void bar2() {
final Value v = call();
System.out.println(v.hashCode());
if (Value.isNotNull(v)) {
}
}
Value call() {return new Value();}
}