contract inference: honor delegate notnullness

This commit is contained in:
peter
2014-09-01 20:28:36 +02:00
parent f69054854d
commit 9fd3080ca5
2 changed files with 39 additions and 4 deletions
@@ -346,6 +346,31 @@ class ContractInferenceFromSourceTest extends LightCodeInsightFixtureTestCase {
assert c == ['null -> null', '!null -> !null']
}
public void "test use delegated method notnull"() {
def c = inferContracts("""
final Object foo(Object bar) {
return doo();
}
@org.jetbrains.annotations.NotNull Object doo() {}
""")
assert c == ['_ -> !null']
}
public void "test use delegated method notnull with contracts"() {
def c = inferContracts("""
final Object foo(Object bar, Object o2) {
return doo(o2);
}
@org.jetbrains.annotations.NotNull Object doo(Object o) {
if (o == null) throw new RuntimeException();
return smth();
}
""")
assert c == ['_, null -> fail', '_, _ -> !null']
}
private String inferContract(String method) {
return assertOneElement(inferContracts(method))
}