Revert "K1: unify code around resolveCallWithGivenDescriptors"
This reverts commit 0bd06b4095.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.resolve.calls;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
|
||||
@@ -47,7 +48,6 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValueWithSmartCastInfo;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
@@ -266,10 +266,23 @@ public class CallResolver {
|
||||
@NotNull Call call,
|
||||
@NotNull Collection<FunctionDescriptor> functionDescriptors
|
||||
) {
|
||||
TracingStrategy tracingStrategy = TracingStrategyImpl.create(expression, call);
|
||||
return resolveCallWithGivenDescriptors(
|
||||
context, call, functionDescriptors, tracingStrategy, null, null, null
|
||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
|
||||
|
||||
OverloadResolutionResults<FunctionDescriptor> resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
||||
callResolutionContext,
|
||||
functionDescriptors,
|
||||
TracingStrategyImpl.create(expression, call),
|
||||
KotlinCallKind.FUNCTION,
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
if (resolutionResults.isSingleResult()) {
|
||||
context.trace.record(BindingContext.RESOLVED_CALL, call, resolutionResults.getResultingCall());
|
||||
context.trace.record(BindingContext.CALL, call.getCallElement(), call);
|
||||
}
|
||||
|
||||
return resolutionResults;
|
||||
}
|
||||
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveSetterCall(
|
||||
@@ -309,35 +322,15 @@ public class CallResolver {
|
||||
@NotNull Call call,
|
||||
@NotNull Collection<FunctionDescriptor> functionDescriptors
|
||||
) {
|
||||
TracingStrategy tracingStrategy = TracingStrategyImpl.create(expression, call);
|
||||
ReceiverValueWithSmartCastInfo dispatchReceiverValue =
|
||||
NewResolutionOldInferenceKt.transformToReceiverWithSmartCastInfo(context, receiver);
|
||||
return resolveCallWithGivenDescriptors(
|
||||
context, call, functionDescriptors, tracingStrategy, null, null, dispatchReceiverValue
|
||||
);
|
||||
}
|
||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
|
||||
|
||||
@NotNull
|
||||
public <D extends CallableDescriptor> OverloadResolutionResults<D> resolveCallWithGivenDescriptors(
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull Call call,
|
||||
@NotNull Collection<D> descriptors,
|
||||
@NotNull TracingStrategy tracingStrategy,
|
||||
@Nullable TypeSubstitutor substitutor,
|
||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
|
||||
@Nullable ReceiverValueWithSmartCastInfo dispatchReceiverValue
|
||||
) {
|
||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(
|
||||
context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments
|
||||
);
|
||||
|
||||
OverloadResolutionResults<D> resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
||||
OverloadResolutionResults<FunctionDescriptor> resolutionResults = PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
||||
callResolutionContext,
|
||||
descriptors,
|
||||
tracingStrategy,
|
||||
functionDescriptors,
|
||||
TracingStrategyImpl.create(expression, call),
|
||||
KotlinCallKind.FUNCTION,
|
||||
substitutor,
|
||||
dispatchReceiverValue
|
||||
null,
|
||||
NewResolutionOldInferenceKt.transformToReceiverWithSmartCastInfo(context, receiver)
|
||||
);
|
||||
|
||||
if (resolutionResults.isSingleResult()) {
|
||||
@@ -348,6 +341,29 @@ public class CallResolver {
|
||||
return resolutionResults;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <D extends CallableDescriptor> OverloadResolutionResults<D> resolveCallWithGivenDescriptor(
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull Call call,
|
||||
@NotNull D descriptor,
|
||||
@NotNull TracingStrategy tracingStrategy,
|
||||
@Nullable TypeSubstitutor substitutor,
|
||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(
|
||||
context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments
|
||||
);
|
||||
|
||||
return PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
||||
callResolutionContext,
|
||||
Collections.singletonList(descriptor),
|
||||
tracingStrategy,
|
||||
KotlinCallKind.FUNCTION,
|
||||
substitutor,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(
|
||||
@NotNull BindingTrace trace,
|
||||
|
||||
+8
-3
@@ -630,10 +630,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
ReceiverParameterDescriptor descriptor,
|
||||
KtExpression expression
|
||||
) {
|
||||
BindingTrace trace = context.trace;
|
||||
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList());
|
||||
components.callResolver.resolveCallWithGivenDescriptors(
|
||||
context, call, Collections.singletonList(descriptor), TracingStrategy.EMPTY, null, null, null
|
||||
);
|
||||
OverloadResolutionResults<ReceiverParameterDescriptor> results =
|
||||
components.callResolver.resolveCallWithGivenDescriptor(context, call, descriptor, TracingStrategy.EMPTY, null, null);
|
||||
|
||||
ResolvedCall<?> resolvedCall = results.getResultingCall();
|
||||
|
||||
trace.record(RESOLVED_CALL, call, resolvedCall);
|
||||
trace.record(CALL, expression, call);
|
||||
}
|
||||
|
||||
private static boolean isDeclaredInClass(ReceiverParameterDescriptor receiver) {
|
||||
|
||||
+9
-3
@@ -161,11 +161,17 @@ public class ControlStructureTypingUtils {
|
||||
) {
|
||||
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
|
||||
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings);
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenDescriptors(
|
||||
context, call, Collections.singletonList(function), tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments, null
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenDescriptor(
|
||||
context, call, function, tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments
|
||||
);
|
||||
assert results.isSingleResult() : "Not single result after resolving one known candidate";
|
||||
return results.getResultingCall();
|
||||
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = results.getResultingCall();
|
||||
|
||||
context.trace.record(RESOLVED_CALL, call, resolvedCall);
|
||||
context.trace.record(CALL, call.getCallElement(), call);
|
||||
|
||||
return resolvedCall;
|
||||
}
|
||||
|
||||
private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(
|
||||
|
||||
Reference in New Issue
Block a user