don't infer ->null contracts in scope of @MethodAreNonNullByDefault (addendum to IDEA-160991)

This commit is contained in:
peter
2016-09-21 10:50:31 +02:00
parent 54fabc098c
commit b571394209
2 changed files with 7 additions and 2 deletions
@@ -76,7 +76,7 @@ class ContractInferenceInterpreter {
contracts = boxReturnValues(contracts);
}
List<MethodContract> compatible = ContainerUtil.filter(contracts, contract -> {
if (contract.returnValue == NOT_NULL_VALUE &&
if ((contract.returnValue == NOT_NULL_VALUE || contract.returnValue == NULL_VALUE) &&
NullableNotNullManager.getInstance(myMethod.getProject()).isNotNull(myMethod, false)) {
return false;
}
@@ -24,10 +24,15 @@ class NotNullClass {
return <warning descr="'null' is returned by the method declared as @MethodsAreNotNullByDefault">null</warning>;
}
private Object privateFoo() {
private String privateFoo() {
return <warning descr="'null' is returned by the method declared as @MethodsAreNotNullByDefault">null</warning>;
}
{
String s2 = privateFoo();
int i2 = s2.length();
}
@Nullable
public Object foo2() {
return null;