ContractInference: faster and lazier method notnull check

This commit is contained in:
peter
2014-10-06 19:30:34 +02:00
parent 8739127fe7
commit fa05e3b5e4
@@ -84,10 +84,14 @@ class ContractInferenceInterpreter {
}
List<MethodContract> inferContracts() {
final boolean notNull = NullableNotNullManager.isNotNull(myMethod);
List<MethodContract> contracts = doInferContracts();
if (contracts.isEmpty()) return contracts;
PsiTypeElement typeElement = myMethod.getReturnTypeElement();
final PsiType returnType = typeElement == null ? null : typeElement.getType();
return ContainerUtil.filter(doInferContracts(), new Condition<MethodContract>() {
final boolean notNull = !(returnType instanceof PsiPrimitiveType) &&
NullableNotNullManager.getInstance(myMethod.getProject()).isNotNull(myMethod, false);
return ContainerUtil.filter(contracts, new Condition<MethodContract>() {
@Override
public boolean value(MethodContract contract) {
if (notNull && contract.returnValue == NOT_NULL_VALUE) {