Revert "[FE 1.0] Resolve special construct calls through the new type inference infra"
This reverts commit e66cc9a639.
This commit is contained in:
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||
@@ -46,7 +45,6 @@ import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.KotlinTypeKt;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices;
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingVisitorDispatcher;
|
||||
@@ -293,23 +291,17 @@ public class CallResolver {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public <D extends CallableDescriptor> OverloadResolutionResults<D> resolveCallWithGivenDescriptor(
|
||||
public OverloadResolutionResults<ReceiverParameterDescriptor> resolveThisOrSuperCallWithGivenDescriptor(
|
||||
@NotNull ExpressionTypingContext context,
|
||||
@NotNull Call call,
|
||||
@NotNull D descriptor,
|
||||
@NotNull TracingStrategy tracingStrategy,
|
||||
@Nullable TypeSubstitutor substitutor,
|
||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
@NotNull ReceiverParameterDescriptor descriptor
|
||||
) {
|
||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(
|
||||
context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments
|
||||
);
|
||||
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
|
||||
|
||||
return PSICallResolver.runResolutionAndInferenceForGivenDescriptors(
|
||||
callResolutionContext,
|
||||
Collections.singletonList(descriptor),
|
||||
tracingStrategy,
|
||||
substitutor
|
||||
TracingStrategy.EMPTY
|
||||
);
|
||||
}
|
||||
|
||||
@@ -588,6 +580,27 @@ public class CallResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
public OverloadResolutionResults<FunctionDescriptor> resolveCallWithKnownCandidate(
|
||||
@NotNull Call call,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull ResolutionContext<?> context,
|
||||
@NotNull OldResolutionCandidate<FunctionDescriptor> candidate,
|
||||
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
return callResolvePerfCounter.<OverloadResolutionResults<FunctionDescriptor>>time(() -> {
|
||||
BasicCallResolutionContext basicCallResolutionContext =
|
||||
BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments);
|
||||
|
||||
Set<OldResolutionCandidate<FunctionDescriptor>> candidates = Collections.singleton(candidate);
|
||||
|
||||
ResolutionTask<FunctionDescriptor> resolutionTask = new ResolutionTask<>(
|
||||
new NewResolutionOldInference.ResolutionKind.GivenCandidates(), null, candidates
|
||||
);
|
||||
|
||||
return doResolveCallOrGetCachedResults(basicCallResolutionContext, resolutionTask, tracing);
|
||||
});
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor> OverloadResolutionResults<D> doResolveCallOrGetCachedResults(
|
||||
@NotNull BasicCallResolutionContext context,
|
||||
@NotNull ResolutionTask<D> resolutionTask,
|
||||
|
||||
@@ -147,8 +147,7 @@ class PSICallResolver(
|
||||
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenDescriptors(
|
||||
context: BasicCallResolutionContext,
|
||||
descriptors: Collection<CallableDescriptor>,
|
||||
tracingStrategy: TracingStrategy,
|
||||
substitutor: TypeSubstitutor? = null
|
||||
tracingStrategy: TracingStrategy
|
||||
): OverloadResolutionResults<D> {
|
||||
val isSpecialFunction = descriptors.any { it.name in SPECIAL_FUNCTION_NAMES }
|
||||
val kotlinCall = toKotlinCall(
|
||||
@@ -160,7 +159,7 @@ class PSICallResolver(
|
||||
GivenCandidate(
|
||||
it,
|
||||
dispatchReceiver = null,
|
||||
knownTypeParametersResultingSubstitutor = substitutor
|
||||
knownTypeParametersResultingSubstitutor = null
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ fun KtElement.getCall(context: BindingContext): Call? {
|
||||
else -> element.getCalleeExpressionIfAny()
|
||||
}
|
||||
if (reference != null) {
|
||||
return context[CALL, reference] ?: context[CALL, element]
|
||||
return context[CALL, reference]
|
||||
}
|
||||
return context[CALL, element]
|
||||
}
|
||||
|
||||
+1
-1
@@ -636,7 +636,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
BindingTrace trace = context.trace;
|
||||
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList());
|
||||
OverloadResolutionResults<ReceiverParameterDescriptor> results =
|
||||
components.callResolver.resolveCallWithGivenDescriptor(context, call, descriptor, TracingStrategy.EMPTY, null, null);
|
||||
components.callResolver.resolveThisOrSuperCallWithGivenDescriptor(context, call, descriptor);
|
||||
|
||||
ResolvedCall<?> resolvedCall = results.getResultingCall();
|
||||
|
||||
|
||||
+6
-10
@@ -49,6 +49,7 @@ import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate;
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
||||
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.AnnotationsForResolveUtilsKt;
|
||||
@@ -161,17 +162,12 @@ public class ControlStructureTypingUtils {
|
||||
) {
|
||||
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
|
||||
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings);
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithGivenDescriptor(
|
||||
context, call, function, tracing, knownTypeParameterSubstitutor, dataFlowInfoForArguments
|
||||
);
|
||||
OldResolutionCandidate<FunctionDescriptor> resolutionCandidate =
|
||||
OldResolutionCandidate.create(call, function, knownTypeParameterSubstitutor);
|
||||
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate(
|
||||
call, tracing, context, resolutionCandidate, dataFlowInfoForArguments);
|
||||
assert results.isSingleResult() : "Not single result after resolving one known candidate";
|
||||
|
||||
ResolvedCall<FunctionDescriptor> resolvedCall = results.getResultingCall();
|
||||
|
||||
context.trace.record(RESOLVED_CALL, call, resolvedCall);
|
||||
context.trace.record(CALL, call.getCallElement(), call);
|
||||
|
||||
return resolvedCall;
|
||||
return results.getResultingCall();
|
||||
}
|
||||
|
||||
private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(
|
||||
|
||||
Reference in New Issue
Block a user