inference: cache only results with default policy

completion results should not be cached even if called after resolved conflicts
This commit is contained in:
Anna.Kozlova
2017-11-28 19:25:06 +01:00
parent 642296836b
commit 5998dfed1f
@@ -17,6 +17,7 @@ package com.intellij.psi.impl.source.resolve.graphInference;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.*;
import com.intellij.psi.impl.source.resolve.DefaultParameterTypeInferencePolicy;
import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy;
import com.intellij.psi.impl.source.resolve.graphInference.constraints.ExpressionCompatibilityConstraint;
import com.intellij.psi.infos.MethodCandidateInfo;
@@ -84,13 +85,14 @@ public class InferenceSessionContainer {
if (topLevelCall != null) {
InferenceSession session;
if (MethodCandidateInfo.isOverloadCheck() || !PsiDiamondType.ourDiamondGuard.currentStack().isEmpty() || LambdaUtil.isLambdaParameterCheck()) {
if (MethodCandidateInfo.isOverloadCheck() || !PsiDiamondType.ourDiamondGuard.currentStack().isEmpty() ||
LambdaUtil.isLambdaParameterCheck() || !policy.equals(DefaultParameterTypeInferencePolicy.INSTANCE)) {
session = startTopLevelInference(topLevelCall, policy);
}
else {
session = CachedValuesManager.getCachedValue(topLevelCall,
() -> new CachedValueProvider.Result<>(
startTopLevelInference(topLevelCall, policy),
startTopLevelInference(topLevelCall, DefaultParameterTypeInferencePolicy.INSTANCE),
PsiModificationTracker.MODIFICATION_COUNT));
if (session != null) {