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 =
|
||||
TaskPrioritizer.<CallableDescriptor, FunctionDescriptor>computePrioritizedTasks(context, name, functionReference, CallableDescriptorCollectors.FUNCTIONS_AND_VARIABLES);
|
||||
return doResolveCallOrGetCachedResults(ResolutionResultsCache.FUNCTION_MEMBER_TYPE,
|
||||
context, tasks, CallTransformer.FUNCTION_CALL_TRANSFORMER, functionReference);
|
||||
context, tasks, CallTransformer.FUNCTION_CALL_TRANSFORMER, functionReference);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -133,7 +133,8 @@ public class CallResolver {
|
||||
) {
|
||||
return resolveFunctionCall(BasicCallResolutionContext.create(
|
||||
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
|
||||
@@ -384,10 +385,10 @@ public class CallResolver {
|
||||
context.resolutionResultsCache.recordResolutionResults(callKey, memberType, results);
|
||||
context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve);
|
||||
|
||||
if (results.isSingleResult() && memberType == ResolutionResultsCache.FUNCTION_MEMBER_TYPE) {
|
||||
if (results.isSingleResult()) {
|
||||
CallCandidateResolutionContext<F> callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed(
|
||||
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);
|
||||
|
||||
JetExpression keyExpression = getDeferredComputationKeyExpression(expression);
|
||||
CallCandidateResolutionContext<FunctionDescriptor> storedContextForArgument =
|
||||
CallCandidateResolutionContext<? extends CallableDescriptor> storedContextForArgument =
|
||||
context.resolutionResultsCache.getDeferredComputation(keyExpression);
|
||||
|
||||
PsiElement parent = expression.getParent();
|
||||
if (parent instanceof JetWhenExpression && expression == ((JetWhenExpression) parent).getSubjectExpression()
|
||||
|| (expression instanceof JetFunctionLiteralExpression)) {
|
||||
return;
|
||||
}
|
||||
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);
|
||||
checkResultArgumentType(type, argument, context);
|
||||
return;
|
||||
}
|
||||
|
||||
CallCandidateResolutionContext<FunctionDescriptor> contextForArgument = storedContextForArgument
|
||||
CallCandidateResolutionContext<? extends CallableDescriptor> contextForArgument = storedContextForArgument
|
||||
.replaceContextDependency(INDEPENDENT).replaceBindingTrace(context.trace).replaceExpectedType(expectedType);
|
||||
JetType type;
|
||||
if (contextForArgument.candidateCall.hasIncompleteTypeParameters()) {
|
||||
|
||||
+2
-3
@@ -55,10 +55,9 @@ public interface ResolutionResultsCache {
|
||||
|
||||
<D extends CallableDescriptor> void recordDeferredComputationForCall(
|
||||
@NotNull CallKey callKey,
|
||||
@NotNull CallCandidateResolutionContext<D> deferredComputation,
|
||||
@NotNull MemberType memberType
|
||||
@NotNull CallCandidateResolutionContext<D> deferredComputation
|
||||
);
|
||||
|
||||
@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();
|
||||
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, CallCandidateResolutionContext<FunctionDescriptor>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice();
|
||||
public static final WritableSlice<CallKey, CallCandidateResolutionContext<? extends CallableDescriptor>> DEFERRED_COMPUTATION_FOR_CALL = Slices.createSimpleSlice();
|
||||
|
||||
static {
|
||||
BasicWritableSlice.initSliceDebugNames(ResolutionResultsCacheImpl.class);
|
||||
@@ -78,22 +78,19 @@ public class ResolutionResultsCacheImpl implements ResolutionResultsCache {
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void recordDeferredComputationForCall(
|
||||
@NotNull CallKey callKey,
|
||||
@NotNull CallCandidateResolutionContext<D> deferredComputation,
|
||||
@NotNull MemberType memberType
|
||||
@NotNull CallCandidateResolutionContext<D> deferredComputation
|
||||
) {
|
||||
if (memberType == PROPERTY_MEMBER_TYPE) return;
|
||||
//noinspection unchecked
|
||||
trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, (CallCandidateResolutionContext<FunctionDescriptor>) deferredComputation);
|
||||
trace.record(DEFERRED_COMPUTATION_FOR_CALL, callKey, deferredComputation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CallCandidateResolutionContext<FunctionDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
||||
public CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
||||
if (expression == null) return null;
|
||||
for (Call.CallType callType : Lists
|
||||
.newArrayList(Call.CallType.DEFAULT, Call.CallType.ARRAY_GET_METHOD, Call.CallType.ARRAY_SET_METHOD)) {
|
||||
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) {
|
||||
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.Nullable;
|
||||
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.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace;
|
||||
@@ -77,16 +76,15 @@ public class TemporaryResolutionResultsCache implements ResolutionResultsCache {
|
||||
@Override
|
||||
public <D extends CallableDescriptor> void recordDeferredComputationForCall(
|
||||
@NotNull CallKey callKey,
|
||||
@NotNull CallCandidateResolutionContext<D> deferredComputation,
|
||||
@NotNull MemberType memberType
|
||||
@NotNull CallCandidateResolutionContext<D> deferredComputation
|
||||
) {
|
||||
innerCache.recordDeferredComputationForCall(callKey, deferredComputation, memberType);
|
||||
innerCache.recordDeferredComputationForCall(callKey, deferredComputation);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CallCandidateResolutionContext<FunctionDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
||||
CallCandidateResolutionContext<FunctionDescriptor> computation = innerCache.getDeferredComputation(expression);
|
||||
public CallCandidateResolutionContext<? extends CallableDescriptor> getDeferredComputation(@Nullable JetExpression expression) {
|
||||
CallCandidateResolutionContext<? extends CallableDescriptor> computation = innerCache.getDeferredComputation(expression);
|
||||
if (computation != null) {
|
||||
return computation;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user