mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
contract inference: don't go inside try because catch/finally clauses can change the outcome completely
This commit is contained in:
-6
@@ -370,12 +370,6 @@ class ContractInferenceInterpreter {
|
||||
else if (statement instanceof PsiDoWhileStatement) {
|
||||
result.addAll(visitStatements(states, ((PsiDoWhileStatement)statement).getBody()));
|
||||
}
|
||||
else if (statement instanceof PsiTryStatement) {
|
||||
PsiCodeBlock block = ((PsiTryStatement)statement).getTryBlock();
|
||||
if (block != null) {
|
||||
result.addAll(visitStatements(states, block.getStatements()));
|
||||
}
|
||||
}
|
||||
|
||||
break; // visit only the first statement unless it's 'if' whose 'then' always returns and the next statement is effectively 'else'
|
||||
}
|
||||
|
||||
-13
@@ -334,19 +334,6 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
|
||||
assert c == ['null -> null']
|
||||
}
|
||||
|
||||
public void "test go inside try"() {
|
||||
def c = inferContracts("""
|
||||
final Object foo(Object bar) {
|
||||
try {
|
||||
if (bar == null) return null;
|
||||
bar = smth(bar);
|
||||
} finally {}
|
||||
return new String("abc");
|
||||
}
|
||||
""")
|
||||
assert c == ['null -> null']
|
||||
}
|
||||
|
||||
public void "test use invoked method notnull"() {
|
||||
def c = inferContracts("""
|
||||
final Object foo(Object bar) {
|
||||
|
||||
Reference in New Issue
Block a user