contract inference: don't go inside try because catch/finally clauses can change the outcome completely

This commit is contained in:
peter
2014-09-01 10:43:30 +02:00
parent fdd3376d7a
commit 5ac0709ec3
2 changed files with 0 additions and 19 deletions
@@ -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'
}
@@ -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) {