mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-08 15:09:39 +07:00
IDEA-101689 incorrect control-flow analisys
This commit is contained in:
@@ -1218,7 +1218,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
ConditionalGotoInstruction cond = new ConditionalGotoInstruction(NOT_FOUND, false, null);
|
||||
addInstruction(cond);
|
||||
addInstruction(new EmptyStackInstruction());
|
||||
addInstruction(new PushInstruction(myFactory.getTypeFactory().create(ref), null));
|
||||
addInstruction(new PushInstruction(myFactory.getNotNullFactory().create(ref), null));
|
||||
addThrowCode(ref);
|
||||
cond.setOffset(myCurrentFlow.getInstructionCount());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
class MyException extends Exception {}
|
||||
|
||||
class Foo {
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
bar();
|
||||
} catch (Exception e) {
|
||||
if (e instanceof MyException) {
|
||||
return;
|
||||
}
|
||||
if (<warning descr="Condition 'e instanceof RuntimeException' is always 'true'">e instanceof RuntimeException</warning>) {
|
||||
return;
|
||||
}
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void bar() throws MyException {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -90,6 +90,7 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
public void testReturningNullFromVoidMethod() throws Throwable { doTest(); }
|
||||
|
||||
public void testCatchRuntimeException() throws Throwable { doTest(); }
|
||||
public void testNotNullCatchParameter() { doTest(); }
|
||||
|
||||
public void testAssertFailInCatch() throws Throwable {
|
||||
myFixture.addClass("package org.junit; public class Assert { public static void fail() {}}");
|
||||
|
||||
Reference in New Issue
Block a user