mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ControlFlowAnalyzer: pop result of resource expression (Java 9)
If it's not popped, it causes misbalanced stack which may lead to exceptions/strange behavior in data flow analysis.
This commit is contained in:
+1
@@ -972,6 +972,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
}
|
||||
else if (resource instanceof PsiResourceExpression) {
|
||||
((PsiResourceExpression)resource).getExpression().accept(this);
|
||||
addInstruction(new PopInstruction());
|
||||
}
|
||||
|
||||
final List<PsiClassType> closerExceptions = ExceptionUtil.getCloserExceptions(resource);
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
class Test {
|
||||
public void closeable(AutoCloseable y) {
|
||||
try(<error descr="Resource references are not supported at language level '1.7'">y</error>) {
|
||||
System.out.println("Hello");
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void incompleteCode(AutoCloseable y) {
|
||||
try(<error descr="Resource references are not supported at language level '1.7'">y</error><error descr="')' expected"> </error>{
|
||||
System.out.println("Hello");
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -546,4 +546,6 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testGetterOfNullableFieldIsNotAnnotated() { doTest(); }
|
||||
|
||||
public void testGetterOfNullableFieldIsNotNull() { doTest(); }
|
||||
|
||||
public void testTryWithResourceExpressions() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user