From fa05e3b5e439a3038278e2627d4f1752c8daa364 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 6 Oct 2014 19:29:08 +0200 Subject: [PATCH] ContractInference: faster and lazier method notnull check --- .../codeInspection/dataFlow/ContractInference.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java index 63df26ff3e17..a23da345e7cb 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/ContractInference.java @@ -84,10 +84,14 @@ class ContractInferenceInterpreter { } List inferContracts() { - final boolean notNull = NullableNotNullManager.isNotNull(myMethod); + List 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() { + final boolean notNull = !(returnType instanceof PsiPrimitiveType) && + NullableNotNullManager.getInstance(myMethod.getProject()).isNotNull(myMethod, false); + return ContainerUtil.filter(contracts, new Condition() { @Override public boolean value(MethodContract contract) { if (notNull && contract.returnValue == NOT_NULL_VALUE) {