[java-dfa] Stop analysis completely after impossible cast outside of try-catch

Improves UnreachableCodeInspection

GitOrigin-RevId: 87a98ad8c3c0ca544e86c9bb1c98267dc939a728
This commit is contained in:
Tagir Valeev
2024-01-26 22:02:05 +00:00
committed by intellij-monorepo-bot
parent 557fbd5c52
commit 434301c3b9
3 changed files with 13 additions and 1 deletions
@@ -103,7 +103,9 @@ public class TypeCastInstruction extends ExpressionPushingInstruction {
}
}
result.add(nextState(interpreter, stateBefore));
if (castPossible) {
result.add(nextState(interpreter, stateBefore));
}
pushResult(interpreter, stateBefore, stateBefore.pop());
}
UnsatisfiedConditionProblem problem = getConditionProblem();
@@ -0,0 +1,8 @@
class Test {
public static void main(String[] args) {
Object o = "12";
Integer a = (Integer) o;
<warning descr="Unreachable code">System.out.println("1");</warning>
}
}
@@ -39,6 +39,8 @@ public class UnreachableCodeInspectionTest extends LightJavaCodeInsightFixtureTe
public void testCatchLinkageError() { doTest(); }
public void testLambdaCast() { doTest(); }
public void testFailingCast() { doTest(); }
private void doTest() {
myFixture.configureByFile(getTestName(false) + ".java");