[FE 1.0] Get rid of OldResolutionCandidate and its usages
This commit is contained in:
committed by
teamcity
parent
9be181f1ad
commit
d89fa8dea9
@@ -189,7 +189,7 @@ public class CallResolver {
|
||||
@NotNull NewResolutionOldInference.ResolutionKind kind
|
||||
) {
|
||||
return callResolvePerfCounter.<OverloadResolutionResults<D>>time(() -> {
|
||||
ResolutionTask<D> resolutionTask = new ResolutionTask<>(kind, name, null);
|
||||
ResolutionTask<D> resolutionTask = new ResolutionTask<>(kind, name);
|
||||
return doResolveCallOrGetCachedResults(context, resolutionTask, tracing);
|
||||
});
|
||||
}
|
||||
@@ -574,20 +574,14 @@ public class CallResolver {
|
||||
|
||||
@Nullable
|
||||
final Name name;
|
||||
|
||||
@Nullable
|
||||
final Collection<OldResolutionCandidate<D>> givenCandidates;
|
||||
|
||||
@NotNull
|
||||
final NewResolutionOldInference.ResolutionKind resolutionKind;
|
||||
|
||||
private ResolutionTask(
|
||||
@NotNull NewResolutionOldInference.ResolutionKind kind,
|
||||
@Nullable Name name,
|
||||
@Nullable Collection<OldResolutionCandidate<D>> candidates
|
||||
@Nullable Name name
|
||||
) {
|
||||
this.name = name;
|
||||
givenCandidates = candidates;
|
||||
resolutionKind = kind;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.resolve.calls.util.CallResolverUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
|
||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus;
|
||||
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.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.*;
|
||||
@@ -49,17 +48,6 @@ import static org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.UNKNOW
|
||||
|
||||
public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableResolvedCall<D> {
|
||||
private static final Logger LOG = Logger.getInstance(ResolvedCallImpl.class);
|
||||
|
||||
@NotNull
|
||||
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(
|
||||
@NotNull OldResolutionCandidate<D> candidate,
|
||||
@NotNull DelegatingBindingTrace trace,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
return new ResolvedCallImpl<>(candidate, trace, tracing, dataFlowInfoForArguments);
|
||||
}
|
||||
|
||||
private final Call call;
|
||||
private final D candidateDescriptor;
|
||||
private D resultingDescriptor; // Probably substituted
|
||||
@@ -84,27 +72,6 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
|
||||
private boolean completed = false;
|
||||
private KotlinType smartCastDispatchReceiverType = null;
|
||||
private Queue<Function0<Unit>> remainingTasks = null;
|
||||
|
||||
private ResolvedCallImpl(
|
||||
@NotNull OldResolutionCandidate<D> candidate,
|
||||
@NotNull DelegatingBindingTrace trace,
|
||||
@NotNull TracingStrategy tracing,
|
||||
@NotNull MutableDataFlowInfoForArguments dataFlowInfoForArguments
|
||||
) {
|
||||
this.call = candidate.getCall();
|
||||
this.candidateDescriptor = candidate.getDescriptor();
|
||||
this.dispatchReceiver = candidate.getDispatchReceiver();
|
||||
this.extensionReceiver = null; // ResolutionCandidate can have only dispatch receiver
|
||||
this.explicitReceiverKind = candidate.getExplicitReceiverKind();
|
||||
this.knownTypeParametersSubstitutor = candidate.getKnownTypeParametersResultingSubstitutor();
|
||||
this.trace = trace;
|
||||
this.tracing = tracing;
|
||||
this.dataFlowInfoForArguments = dataFlowInfoForArguments;
|
||||
this.typeArguments = createTypeArgumentsMap(candidateDescriptor);
|
||||
this.valueArguments = createValueArgumentsMap(candidateDescriptor);
|
||||
this.argumentToParameterMap = createArgumentsToParameterMap(candidateDescriptor);
|
||||
}
|
||||
|
||||
public ResolvedCallImpl(
|
||||
@NotNull Call call,
|
||||
@NotNull D candidateDescriptor,
|
||||
|
||||
-103
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.tasks;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.kotlin.psi.Call;
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
|
||||
import org.jetbrains.kotlin.types.TypeSubstitutor;
|
||||
|
||||
public class OldResolutionCandidate<D extends CallableDescriptor> {
|
||||
private final Call call;
|
||||
private final D candidateDescriptor;
|
||||
private final TypeSubstitutor knownTypeParametersResultingSubstitutor;
|
||||
private ReceiverValue dispatchReceiver; // receiver object of a method
|
||||
private ExplicitReceiverKind explicitReceiverKind;
|
||||
|
||||
private OldResolutionCandidate(
|
||||
@NotNull Call call, @NotNull D descriptor, @Nullable ReceiverValue dispatchReceiver,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind,
|
||||
@Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
|
||||
) {
|
||||
this.call = call;
|
||||
this.candidateDescriptor = descriptor;
|
||||
this.dispatchReceiver = dispatchReceiver;
|
||||
this.explicitReceiverKind = explicitReceiverKind;
|
||||
this.knownTypeParametersResultingSubstitutor = knownTypeParametersResultingSubstitutor;
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OldResolutionCandidate<D> create(
|
||||
@NotNull Call call, @NotNull D descriptor
|
||||
) {
|
||||
return new OldResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OldResolutionCandidate<D> create(
|
||||
@NotNull Call call, @NotNull D descriptor, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
|
||||
) {
|
||||
return new OldResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
|
||||
knownTypeParametersResultingSubstitutor);
|
||||
}
|
||||
|
||||
public static <D extends CallableDescriptor> OldResolutionCandidate<D> create(
|
||||
@NotNull Call call, @NotNull D descriptor, @Nullable ReceiverValue dispatchReceiver,
|
||||
@NotNull ExplicitReceiverKind explicitReceiverKind,
|
||||
@Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
|
||||
) {
|
||||
return new OldResolutionCandidate<>(call, descriptor, dispatchReceiver, explicitReceiverKind, knownTypeParametersResultingSubstitutor);
|
||||
}
|
||||
|
||||
public void setDispatchReceiver(@Nullable ReceiverValue dispatchReceiver) {
|
||||
this.dispatchReceiver = dispatchReceiver;
|
||||
}
|
||||
|
||||
public void setExplicitReceiverKind(@NotNull ExplicitReceiverKind explicitReceiverKind) {
|
||||
this.explicitReceiverKind = explicitReceiverKind;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Call getCall() {
|
||||
return call;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public D getDescriptor() {
|
||||
return candidateDescriptor;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ReceiverValue getDispatchReceiver() {
|
||||
return dispatchReceiver;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ExplicitReceiverKind getExplicitReceiverKind() {
|
||||
return explicitReceiverKind;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TypeSubstitutor getKnownTypeParametersResultingSubstitutor() {
|
||||
return knownTypeParametersResultingSubstitutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return candidateDescriptor.toString();
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.resolve.calls.results.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.DynamicCallableDescriptors
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
|
||||
import org.jetbrains.kotlin.resolve.calls.util.*
|
||||
import org.jetbrains.kotlin.resolve.checkers.PassingProgressionAsCollectionCallChecker
|
||||
@@ -173,38 +172,6 @@ class PSICallResolver(
|
||||
}
|
||||
}
|
||||
|
||||
// actually, `D` is at least FunctionDescriptor, but right now because of CallResolver it isn't possible change upper bound for `D`
|
||||
fun <D : CallableDescriptor> runResolutionAndInferenceForGivenOldCandidates(
|
||||
context: BasicCallResolutionContext,
|
||||
resolutionCandidates: Collection<OldResolutionCandidate<D>>,
|
||||
tracingStrategy: TracingStrategy
|
||||
): OverloadResolutionResults<D> {
|
||||
val dispatchReceiver = resolutionCandidates.firstNotNullOfOrNull { it.dispatchReceiver }
|
||||
|
||||
val isSpecialFunction = resolutionCandidates.any { it.descriptor.name in SPECIAL_FUNCTION_NAMES }
|
||||
val kotlinCall = toKotlinCall(
|
||||
context, KotlinCallKind.FUNCTION, context.call, givenCandidatesName, tracingStrategy, isSpecialFunction, dispatchReceiver
|
||||
)
|
||||
val scopeTower = ASTScopeTower(context)
|
||||
val resolutionCallbacks = createResolutionCallbacks(context)
|
||||
|
||||
val givenCandidates = resolutionCandidates.map {
|
||||
GivenCandidate(
|
||||
it.descriptor as FunctionDescriptor,
|
||||
it.dispatchReceiver?.let { context.transformToReceiverWithSmartCastInfo(it) },
|
||||
it.knownTypeParametersResultingSubstitutor
|
||||
)
|
||||
}
|
||||
|
||||
val result = kotlinCallResolver.resolveAndCompleteGivenCandidates(
|
||||
scopeTower, resolutionCallbacks, kotlinCall, calculateExpectedType(context), givenCandidates, context.collectAllCandidates
|
||||
)
|
||||
val overloadResolutionResults = convertToOverloadResolutionResults<D>(context, result, tracingStrategy)
|
||||
return overloadResolutionResults.also {
|
||||
clearCacheForApproximationResults()
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearCacheForApproximationResults() {
|
||||
// Mostly, we approximate captured or some other internal types that don't live longer than resolve for a call,
|
||||
// so it's quite useless to preserve cache for longer time
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
|
||||
import org.jetbrains.kotlin.serialization.deserialization.TypeDeserializer
|
||||
@@ -185,7 +184,6 @@ class LazyOperationsLog(
|
||||
}
|
||||
}.appendQuoted()
|
||||
}
|
||||
o is OldResolutionCandidate<*> -> DescriptorRenderer.COMPACT.render(o.descriptor).appendQuoted()
|
||||
}
|
||||
return sb.toString()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user