dfa: fix too complex assertTrue (added state defensive copying)

This commit is contained in:
peter
2014-06-11 21:00:32 +02:00
parent 54783affda
commit aad6407ebf
3 changed files with 21 additions and 1 deletions
@@ -254,7 +254,9 @@ public class StandardInstructionVisitor extends InstructionVisitor {
DfaValue condition = factory.getRelationFactory().createRelation(argValue, expectedValue, EQEQ, invertCondition);
if (condition == null) {
if (!(argValue instanceof DfaConstValue)) {
falseStates.addAll(states);
for (DfaMemoryState state : states) {
falseStates.add(state.createCopy());
}
continue;
}
condition = constFactory.createFromValue((argValue == expectedValue) != invertCondition, PsiType.BOOLEAN, null);
@@ -0,0 +1,17 @@
import org.jetbrains.annotations.Contract;
import java.util.List;
abstract class Some {
@Contract("_,false->fail")
abstract void assertTrue(String s, boolean b);
void assertContainsAllVariants(List<String> actualVariants, String... expectedVariants) {
for (String expectedVariant : expectedVariants) {
assertTrue(expectedVariant, actualVariants.contains(expectedVariant));
}
}
}
@@ -235,6 +235,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
public void testManySequentialInstanceofsNotComplex() { doTest(); }
public void testLongDisjunctionsNotComplex() { doTest(); }
public void testWhileNotComplex() { doTest(); }
public void testAssertTrueNotComplex() { doTest(); }
public void testManyDisjunctiveFieldAssignmentsInLoopNotComplex() { doTest(); }
public void testManyContinuesNotComplex() { doTest(); }
public void testFinallyNotComplex() { doTest(); }