[java-dfa] Properly balance stack when increment/decrement variable is unresolved

Found by property tests

GitOrigin-RevId: 581bc8d7a12cc43037a3936126a68cdf3678e884
This commit is contained in:
Tagir Valeev
2022-10-31 22:02:06 +00:00
committed by intellij-monorepo-bot
parent 6f250ab078
commit 5504efe286
3 changed files with 13 additions and 0 deletions
@@ -2172,6 +2172,8 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
}
PsiPrimitiveType unboxedType = PsiPrimitiveType.getOptionallyUnboxedType(operandType);
if (unboxedType == null) {
// Unknown type; likely erroneous code: replace old_value with unknown
addInstruction(new PopInstruction());
pushUnknown();
} else {
generateBoxingUnboxingInstructionFor(operand, unboxedType);
@@ -0,0 +1,10 @@
import java.util.*;
class Test {
void test(int last)
{
for (; <error descr="Cannot resolve symbol 'i'">i</error> < last; <error descr="Cannot resolve symbol 'i'">i</error>++) {
}
}
}
@@ -89,4 +89,5 @@ public class DataFlowRangeAnalysisTest extends DataFlowInspectionTestCase {
public void testFloatingPointCasts() { doTest(); }
public void testFloatingPointMaxLoop() { doTest(); }
public void testStringIndexOfRelation() { doTest(); }
public void testIncompleteLoop() { doTest(); }
}