Cache resolution results for properties as well.
There is no need to complete these results with expected type and analyze arguments, as property doesn't have arguments. However, it's useful to clean internal resolution data through completion phase for properties like for functions.
This commit is contained in:
@@ -120,7 +120,7 @@ public class CallResolver {
|
|||||||
List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> tasks =
|
List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> tasks =
|
||||||
TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasks(context, name, functionReference, CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES);
|
TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasks(context, name, functionReference, CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES);
|
||||||
return doResolveCallOrGetCachedResults(ResolutionResultsCache.FUNCTION_MEMBER_TYPE,
|
return doResolveCallOrGetCachedResults(ResolutionResultsCache.FUNCTION_MEMBER_TYPE,
|
||||||
context, tasks, CallTransformer.FUNCTION_CALL_TRANSFORMER, functionReference);
|
context, tasks, CallTransformer.FUNCTION_CALL_TRANSFORMER, functionReference);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -133,7 +133,8 @@ public class CallResolver {
|
|||||||
) {
|
) {
|
||||||
return resolveFunctionCall(BasicCallResolutionContext.create(
|
return resolveFunctionCall(BasicCallResolutionContext.create(
|
||||||
trace, scope, call, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckValueArgumentsMode.ENABLED,
|
trace, scope, call, expectedType, dataFlowInfo, ContextDependency.INDEPENDENT, CheckValueArgumentsMode.ENABLED,
|
||||||
ExpressionPosition.FREE, ResolutionResultsCacheImpl.create(), LabelResolver.create(), null, expressionTypingServices.createExtension(scope)));
|
ExpressionPosition.FREE, ResolutionResultsCacheImpl.create(), LabelResolver.create(), null,
|
||||||
|
expressionTypingServices.createExtension(scope)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -384,10 +385,10 @@ public class CallResolver {
|
|||||||
context.resolutionResultsCache.recordResolutionResults(callKey, memberType, results);
|
context.resolutionResultsCache.recordResolutionResults(callKey, memberType, results);
|
||||||
context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve);
|
context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve);
|
||||||
|
|
||||||
if (results.isSingleResult() && memberType == ResolutionResultsCache.FUNCTION_MEMBER_TYPE) {
|
if (results.isSingleResult()) {
|
||||||
CallCandidateResolutionContext<F> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(
|
CallCandidateResolutionContext<F> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(
|
||||||
results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing);
|
results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing);
|
||||||
context.resolutionResultsCache.recordDeferredComputationForCall(callKey, callCandidateResolutionContext, memberType);
|
context.resolutionResultsCache.recordDeferredComputationForCall(callKey, callCandidateResolutionContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -347,21 +347,21 @@ public class CandidateResolver {
|
|||||||
context = context.replaceExpectedType(expectedType);
|
context = context.replaceExpectedType(expectedType);
|
||||||
|
|
||||||
JetExpression keyExpression = getDeferredComputationKeyExpression(expression);
|
JetExpression keyExpression = getDeferredComputationKeyExpression(expression);
|
||||||
CallCandidateResolutionContext<FunctionDescriptor> storedContextForArgument =
|
CallCandidateResolutionContext<? extends CallableDescriptor> storedContextForArgument =
|
||||||
context.resolutionResultsCache.getDeferredComputation(keyExpression);
|
context.resolutionResultsCache.getDeferredComputation(keyExpression);
|
||||||
|
|
||||||
|
PsiElement parent = expression.getParent();
|
||||||
|
if (parent instanceof JetWhenExpression && expression == ((JetWhenExpression) parent).getSubjectExpression()
|
||||||
|
|| (expression instanceof JetFunctionLiteralExpression)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (storedContextForArgument == null) {
|
if (storedContextForArgument == null) {
|
||||||
PsiElement parent = expression.getParent();
|
|
||||||
if (parent instanceof JetWhenExpression && expression == ((JetWhenExpression) parent).getSubjectExpression()
|
|
||||||
|| (expression instanceof JetFunctionLiteralExpression)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
JetType type = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression);
|
JetType type = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression);
|
||||||
checkResultArgumentType(type, argument, context);
|
checkResultArgumentType(type, argument, context);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CallCandidateResolutionContext<FunctionDescriptor> contextForArgument = storedContextForArgument
|
CallCandidateResolutionContext<? extends CallableDescriptor> contextForArgument = storedContextForArgument
|
||||||
.replaceContextDependency(INDEPENDENT).replaceBindingTrace(context.trace).replaceExpectedType(expectedType);
|
.replaceContextDependency(INDEPENDENT).replaceBindingTrace(context.trace).replaceExpectedType(expectedType);
|
||||||
JetType type;
|
JetType type;
|
||||||
if (contextForArgument.candidateCall.hasIncompleteTypeParameters()) {
|
if (contextForArgument.candidateCall.hasIncompleteTypeParameters()) {
|
||||||
|
|||||||
+2
-3
@@ -55,10 +55,9 @@ public interface ResolutionResultsCache {
|
|||||||
|
|
||||||
<D extends CallableDescriptor> void recordDeferredComputationForCall(
|
<D extends CallableDescriptor> void recordDeferredComputationForCall(
|
||||||
@NotNull CallKey callKey,
|
@NotNull CallKey callKey,
|
||||||
@NotNull CallCandidateResolutionContext<D> deferredComputation,
|
@NotNull CallCandidateResolutionContext<D> deferredComputation
|
||||||
@NotNull MemberType memberType
|
|
||||||
);
|
);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
CallCandidateResolutionContext<FunctionDescriptor> getDeferredComputation(@Nullable JetExpression expression);
|
CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-8
@@ -37,7 +37,7 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
|
|||||||
RESOLUTION_RESULTS_FOR_FUNCTION = Slices.createSimpleSlice();
|
RESOLUTION_RESULTS_FOR_FUNCTION = Slices.createSimpleSlice();
|
||||||
public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<VariableDescriptor>> RESOLUTION_RESULTS_FOR_PROPERTY = Slices.createSimpleSlice();
|
public static final WritableSlice<CallKey, OverloadResolutionResultsImpl<VariableDescriptor>> RESOLUTION_RESULTS_FOR_PROPERTY = Slices.createSimpleSlice();
|
||||||
public static final WritableSlice<CallKey, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice();
|
public static final WritableSlice<CallKey, DelegatingBindingTrace> TRACE_DELTAS_CACHE = Slices.createSimpleSlice();
|
||||||
public static final WritableSlice<CallKey, CallCandidateResolutionContext<FunctionDescriptor>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice();
|
public static final WritableSlice<CallKey, CallCandidateResolutionContext<? extends CallableDescriptor>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class);
|
BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class);
|
||||||
@@ -78,22 +78,19 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
|
|||||||
@Override
|
@Override
|
||||||
public <D extends CallableDescriptor> void recordDeferredComputationForCall(
|
public <D extends CallableDescriptor> void recordDeferredComputationForCall(
|
||||||
@NotNull CallKey callKey,
|
@NotNull CallKey callKey,
|
||||||
@NotNull CallCandidateResolutionContext<D> deferredComputation,
|
@NotNull CallCandidateResolutionContext<D> deferredComputation
|
||||||
@NotNull MemberType memberType
|
|
||||||
) {
|
) {
|
||||||
if (memberType == PROPERTY_MEMBER_TYPE) return;
|
trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, deferredComputation);
|
||||||
//noinspection unchecked
|
|
||||||
trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, (CallCandidateResolutionContext<FunctionDescriptor>) deferredComputation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public CallCandidateResolutionContext<FunctionDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
public CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
||||||
if (expression == null) return null;
|
if (expression == null) return null;
|
||||||
for (Call.CallType callType : Lists
|
for (Call.CallType callType : Lists
|
||||||
.newArrayList(Call.CallType.DEFAULT, Call.CallType.ARRAY_GET_METHOD, Call.CallType.ARRAY_SET_METHOD)) {
|
.newArrayList(Call.CallType.DEFAULT, Call.CallType.ARRAY_GET_METHOD, Call.CallType.ARRAY_SET_METHOD)) {
|
||||||
CallKey callKey = CallKey.create(callType, expression);
|
CallKey callKey = CallKey.create(callType, expression);
|
||||||
CallCandidateResolutionContext<FunctionDescriptor> context = trace.get(DEFERRED_COMPUTATION_FOR_CALL, callKey);
|
CallCandidateResolutionContext<? extends CallableDescriptor> context = trace.get(DEFERRED_COMPUTATION_FOR_CALL, callKey);
|
||||||
if (context != null) {
|
if (context != null) {
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-6
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve.calls.context;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
|
||||||
import org.jetbrains.jet.lang.psi.CallKey;
|
import org.jetbrains.jet.lang.psi.CallKey;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||||
@@ -77,16 +76,15 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
|
|||||||
@Override
|
@Override
|
||||||
public <D extends CallableDescriptor> void recordDeferredComputationForCall(
|
public <D extends CallableDescriptor> void recordDeferredComputationForCall(
|
||||||
@NotNull CallKey callKey,
|
@NotNull CallKey callKey,
|
||||||
@NotNull CallCandidateResolutionContext<D> deferredComputation,
|
@NotNull CallCandidateResolutionContext<D> deferredComputation
|
||||||
@NotNull MemberType memberType
|
|
||||||
) {
|
) {
|
||||||
innerCache.recordDeferredComputationForCall(callKey, deferredComputation, memberType);
|
innerCache.recordDeferredComputationForCall(callKey, deferredComputation);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CallCandidateResolutionContext<FunctionDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
public CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
||||||
CallCandidateResolutionContext<FunctionDescriptor> computation = innerCache.getDeferredComputation(expression);
|
CallCandidateResolutionContext<? extends CallableDescriptor> computation = innerCache.getDeferredComputation(expression);
|
||||||
if (computation != null) {
|
if (computation != null) {
|
||||||
return computation;
|
return computation;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user