Rename the old inference ResolutionCandidate to OldResolutionCandidate

This commit is contained in:
Victor Petukhov
2021-09-20 13:30:37 +03:00
parent 623f273251
commit 6082d681b6
10 changed files with 45 additions and 45 deletions
@@ -43,7 +43,7 @@ import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.resolvedCallUtil.getExplicitReceiverValue
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy
import org.jetbrains.kotlin.resolve.findTopMostOverriddenDescriptors
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
@@ -102,7 +102,7 @@ fun getExpectedTypePredicate(
val predicates = ArrayList<TypePredicate>()
for (candidate in candidates) {
val resolutionCandidate = ResolutionCandidate.create(
val resolutionCandidate = OldResolutionCandidate.create(
call,
candidate,
null,
@@ -218,7 +218,7 @@ public class CallResolver {
private <D extends FunctionDescriptor> OverloadResolutionResults<D> computeTasksFromCandidatesAndResolvedCall(
@NotNull BasicCallResolutionContext context,
@NotNull KtReferenceExpression referenceExpression,
@NotNull Collection<ResolutionCandidate<D>> candidates
@NotNull Collection<OldResolutionCandidate<D>> candidates
) {
return computeTasksFromCandidatesAndResolvedCall(context, candidates,
TracingStrategyImpl.create(referenceExpression, context.call));
@@ -227,7 +227,7 @@ public class CallResolver {
@NotNull
private <D extends FunctionDescriptor> OverloadResolutionResults<D> computeTasksFromCandidatesAndResolvedCall(
@NotNull BasicCallResolutionContext context,
@NotNull Collection<ResolutionCandidate<D>> candidates,
@NotNull Collection<OldResolutionCandidate<D>> candidates,
@NotNull TracingStrategy tracing
) {
return callResolvePerfCounter.<OverloadResolutionResults<D>>time(() -> {
@@ -261,8 +261,8 @@ public class CallResolver {
@NotNull Collection<FunctionDescriptor> functionDescriptors
) {
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
List<ResolutionCandidate<FunctionDescriptor>> candidates = CollectionsKt.map(functionDescriptors, descriptor ->
ResolutionCandidate.create(
List<OldResolutionCandidate<FunctionDescriptor>> candidates = CollectionsKt.map(functionDescriptors, descriptor ->
OldResolutionCandidate.create(
call,
descriptor,
null,
@@ -282,8 +282,8 @@ public class CallResolver {
@NotNull Collection<FunctionDescriptor> functionDescriptors
) {
BasicCallResolutionContext callResolutionContext = BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS);
List<ResolutionCandidate<FunctionDescriptor>> resolutionCandidates = CollectionsKt.map(functionDescriptors, descriptor ->
ResolutionCandidate.create(
List<OldResolutionCandidate<FunctionDescriptor>> resolutionCandidates = CollectionsKt.map(functionDescriptors, descriptor ->
OldResolutionCandidate.create(
call, descriptor, receiver, ExplicitReceiverKind.DISPATCH_RECEIVER, null));
return computeTasksFromCandidatesAndResolvedCall(
@@ -412,10 +412,10 @@ public class CallResolver {
@NotNull KtReferenceExpression functionReference,
@NotNull KotlinType constructedType
) {
Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
Pair<Collection<OldResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
prepareCandidatesAndContextForConstructorCall(constructedType, context, syntheticScopes);
Collection<ResolutionCandidate<ConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
Collection<OldResolutionCandidate<ConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
context = candidatesAndContext.getSecond();
return computeTasksFromCandidatesAndResolvedCall(context, functionReference, candidates);
@@ -502,9 +502,9 @@ public class CallResolver {
KotlinType superType =
isThisCall ? currentClassDescriptor.getDefaultType() : DescriptorUtils.getSuperClassType(currentClassDescriptor);
Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
Pair<Collection<OldResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> candidatesAndContext =
prepareCandidatesAndContextForConstructorCall(superType, context, syntheticScopes);
Collection<ResolutionCandidate<ConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
Collection<OldResolutionCandidate<ConstructorDescriptor>> candidates = candidatesAndContext.getFirst();
context = candidatesAndContext.getSecond();
TracingStrategy tracing = call.isImplicit() ?
@@ -529,13 +529,13 @@ public class CallResolver {
}
@NotNull
private static Pair<Collection<ResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> prepareCandidatesAndContextForConstructorCall(
private static Pair<Collection<OldResolutionCandidate<ConstructorDescriptor>>, BasicCallResolutionContext> prepareCandidatesAndContextForConstructorCall(
@NotNull KotlinType superType,
@NotNull BasicCallResolutionContext context,
@NotNull SyntheticScopes syntheticScopes
) {
if (!(superType.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor)) {
return new Pair<>(Collections.<ResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
return new Pair<>(Collections.<OldResolutionCandidate<ConstructorDescriptor>>emptyList(), context);
}
// If any constructor has type parameter (currently it only can be true for ones from Java), try to infer arguments for them
@@ -547,7 +547,7 @@ public class CallResolver {
context = context.replaceExpectedType(superType);
}
List<ResolutionCandidate<ConstructorDescriptor>> candidates =
List<OldResolutionCandidate<ConstructorDescriptor>> candidates =
CallResolverUtilKt.createResolutionCandidatesForConstructors(
context.scope, context.call, superType, !anyConstructorHasDeclaredTypeParameters, syntheticScopes
);
@@ -568,14 +568,14 @@ public class CallResolver {
@NotNull Call call,
@NotNull TracingStrategy tracing,
@NotNull ResolutionContext<?> context,
@NotNull ResolutionCandidate<FunctionDescriptor> candidate,
@NotNull OldResolutionCandidate<FunctionDescriptor> candidate,
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
) {
return callResolvePerfCounter.<OverloadResolutionResults<FunctionDescriptor>>time(() -> {
BasicCallResolutionContext basicCallResolutionContext =
BasicCallResolutionContext.create(context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS, dataFlowInfoForArguments);
Set<ResolutionCandidate<FunctionDescriptor>> candidates = Collections.singleton(candidate);
Set<OldResolutionCandidate<FunctionDescriptor>> candidates = Collections.singleton(candidate);
ResolutionTask<FunctionDescriptor> resolutionTask = new ResolutionTask<>(
new NewResolutionOldInference.ResolutionKind.GivenCandidates(), null, candidates
@@ -737,7 +737,7 @@ public class CallResolver {
final Name name;
@Nullable
final Collection<ResolutionCandidate<D>> givenCandidates;
final Collection<OldResolutionCandidate<D>> givenCandidates;
@NotNull
final NewResolutionOldInference.ResolutionKind resolutionKind;
@@ -745,7 +745,7 @@ public class CallResolver {
private ResolutionTask(
@NotNull NewResolutionOldInference.ResolutionKind kind,
@Nullable Name name,
@Nullable Collection<ResolutionCandidate<D>> candidates
@Nullable Collection<OldResolutionCandidate<D>> candidates
) {
this.name = name;
givenCandidates = candidates;
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
import org.jetbrains.kotlin.resolve.calls.inference.getNestedTypeVariables
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate
import org.jetbrains.kotlin.resolve.descriptorUtil.isParameterOfAnnotation
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.SyntheticScopes
@@ -277,7 +277,7 @@ fun createResolutionCandidatesForConstructors(
typeWithConstructors: KotlinType,
useKnownTypeSubstitutor: Boolean,
syntheticScopes: SyntheticScopes
): List<ResolutionCandidate<ConstructorDescriptor>> {
): List<OldResolutionCandidate<ConstructorDescriptor>> {
val classWithConstructors = typeWithConstructors.constructor.declarationDescriptor as ClassDescriptor
val unwrappedType = typeWithConstructors.unwrap()
@@ -320,7 +320,7 @@ fun createResolutionCandidatesForConstructors(
val syntheticConstructors = constructors.flatMap { syntheticScopes.collectSyntheticConstructors(it) }
return (constructors + syntheticConstructors).map {
ResolutionCandidate.create(call, it, dispatchReceiver, receiverKind, knownSubstitutor)
OldResolutionCandidate.create(call, it, dispatchReceiver, receiverKind, knownSubstitutor)
}
}
@@ -33,7 +33,7 @@ import org.jetbrains.kotlin.resolve.calls.callResolverUtil.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.ResolutionCandidate;
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.*;
@@ -53,7 +53,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
@NotNull
public static <D extends CallableDescriptor> ResolvedCallImpl<D> create(
@NotNull ResolutionCandidate<D> candidate,
@NotNull OldResolutionCandidate<D> candidate,
@NotNull DelegatingBindingTrace trace,
@NotNull TracingStrategy tracing,
@NotNull MutableDataFlowInfoForArguments dataFlowInfoForArguments
@@ -87,7 +87,7 @@ public class ResolvedCallImpl<D extends CallableDescriptor> implements MutableRe
private Queue<Function0<Unit>> remainingTasks = null;
private ResolvedCallImpl(
@NotNull ResolutionCandidate<D> candidate,
@NotNull OldResolutionCandidate<D> candidate,
@NotNull DelegatingBindingTrace trace,
@NotNull TracingStrategy tracing,
@NotNull MutableDataFlowInfoForArguments dataFlowInfoForArguments
@@ -23,14 +23,14 @@ import org.jetbrains.kotlin.psi.Call;
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
import org.jetbrains.kotlin.types.TypeSubstitutor;
public class ResolutionCandidate<D extends CallableDescriptor> {
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 ResolutionCandidate(
private OldResolutionCandidate(
@NotNull Call call, @NotNull D descriptor, @Nullable ReceiverValue dispatchReceiver,
@NotNull ExplicitReceiverKind explicitReceiverKind,
@Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
@@ -42,25 +42,25 @@ public class ResolutionCandidate<D extends CallableDescriptor> {
this.knownTypeParametersResultingSubstitutor = knownTypeParametersResultingSubstitutor;
}
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
public static <D extends CallableDescriptor> OldResolutionCandidate<D> create(
@NotNull Call call, @NotNull D descriptor
) {
return new ResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
return new OldResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
}
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
public static <D extends CallableDescriptor> OldResolutionCandidate<D> create(
@NotNull Call call, @NotNull D descriptor, @Nullable TypeSubstitutor knownTypeParametersResultingSubstitutor
) {
return new ResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
return new OldResolutionCandidate<>(call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
knownTypeParametersResultingSubstitutor);
}
public static <D extends CallableDescriptor> ResolutionCandidate<D> create(
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 ResolutionCandidate<>(call, descriptor, dispatchReceiver, explicitReceiverKind, knownTypeParametersResultingSubstitutor);
return new OldResolutionCandidate<>(call, descriptor, dispatchReceiver, explicitReceiverKind, knownTypeParametersResultingSubstitutor);
}
public void setDispatchReceiver(@Nullable ReceiverValue dispatchReceiver) {
@@ -225,7 +225,7 @@ class NewResolutionOldInference(
fun <D : CallableDescriptor> runResolutionForGivenCandidates(
basicCallContext: BasicCallResolutionContext,
tracing: TracingStrategy,
candidates: Collection<ResolutionCandidate<D>>
candidates: Collection<OldResolutionCandidate<D>>
): OverloadResolutionResultsImpl<D> {
val resolvedCandidates = candidates.map { candidate ->
val candidateTrace = TemporaryBindingTrace.create(basicCallContext.trace, "Context for resolve candidate")
@@ -34,7 +34,7 @@ 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.ResolutionCandidate
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.constants.evaluate.ConstantExpressionEvaluator
@@ -121,7 +121,7 @@ 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> runResolutionAndInferenceForGivenCandidates(
context: BasicCallResolutionContext,
resolutionCandidates: Collection<ResolutionCandidate<D>>,
resolutionCandidates: Collection<OldResolutionCandidate<D>>,
tracingStrategy: TracingStrategy
): OverloadResolutionResults<D> {
val dispatchReceiver = resolutionCandidates.firstNotNullOfOrNull { it.dispatchReceiver }
@@ -58,7 +58,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValue;
import org.jetbrains.kotlin.resolve.calls.smartcasts.Nullability;
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate;
import org.jetbrains.kotlin.resolve.calls.tasks.OldResolutionCandidate;
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
import org.jetbrains.kotlin.resolve.calls.tower.NewAbstractResolvedCall;
import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
@@ -613,8 +613,8 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
) {
BindingTrace trace = context.trace;
Call call = CallMaker.makeCall(expression, null, null, expression, Collections.emptyList());
ResolutionCandidate<ReceiverParameterDescriptor> resolutionCandidate =
ResolutionCandidate.create(
OldResolutionCandidate<ReceiverParameterDescriptor> resolutionCandidate =
OldResolutionCandidate.create(
call, descriptor, null, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, null);
ResolvedCallImpl<ReceiverParameterDescriptor> resolvedCall =
@@ -1003,7 +1003,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
) {
Call call = propertyResolvedCall.getCall();
ResolutionCandidate<PropertySetterDescriptor> resolutionCandidate = ResolutionCandidate.create(
OldResolutionCandidate<PropertySetterDescriptor> resolutionCandidate = OldResolutionCandidate.create(
call, descriptor, propertyResolvedCall.getDispatchReceiver(), propertyResolvedCall.getExplicitReceiverKind(), null
);
@@ -49,7 +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.ResolutionCandidate;
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;
@@ -162,8 +162,8 @@ public class ControlStructureTypingUtils {
) {
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings);
ResolutionCandidate<FunctionDescriptor> resolutionCandidate =
ResolutionCandidate.create(call, function, knownTypeParameterSubstitutor);
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";
@@ -25,7 +25,7 @@ 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.ResolutionCandidate
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 +185,7 @@ class LazyOperationsLog(
}
}.appendQuoted()
}
o is ResolutionCandidate<*> -> DescriptorRenderer.COMPACT.render(o.descriptor).appendQuoted()
o is OldResolutionCandidate<*> -> DescriptorRenderer.COMPACT.render(o.descriptor).appendQuoted()
}
return sb.toString()
}