Minor. change several signatures
This commit is contained in:
@@ -641,7 +641,7 @@ public class CallResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
OverloadResolutionResultsImpl<F> results = resolutionResultsHandler.computeResultAndReportErrors(
|
OverloadResolutionResultsImpl<F> results = resolutionResultsHandler.computeResultAndReportErrors(
|
||||||
task, task.getResolvedCalls());
|
task, task.tracing, task.getResolvedCalls());
|
||||||
if (!results.isSingleResult() && !results.isIncomplete()) {
|
if (!results.isSingleResult() && !results.isIncomplete()) {
|
||||||
argumentTypeResolver.checkTypesWithNoCallee(task.toBasic());
|
argumentTypeResolver.checkTypesWithNoCallee(task.toBasic());
|
||||||
}
|
}
|
||||||
@@ -666,7 +666,7 @@ public class CallResolver {
|
|||||||
Collection<CallCandidateResolutionContext<D>> contexts =
|
Collection<CallCandidateResolutionContext<D>> contexts =
|
||||||
callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace, candidateResolveMode);
|
callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace, candidateResolveMode);
|
||||||
for (CallCandidateResolutionContext<D> context : contexts) {
|
for (CallCandidateResolutionContext<D> context : contexts) {
|
||||||
candidateResolver.performResolutionForCandidateCall(context, task);
|
candidateResolver.performResolutionForCandidateCall(context, task.checkArguments);
|
||||||
candidateResolutionContexts.add(context);
|
candidateResolutionContexts.add(context);
|
||||||
}
|
}
|
||||||
return Unit.INSTANCE$;
|
return Unit.INSTANCE$;
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
|
|||||||
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*
|
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTask
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||||
@@ -63,7 +62,7 @@ public class CandidateResolver(
|
|||||||
|
|
||||||
public fun <D : CallableDescriptor, F : D> performResolutionForCandidateCall(
|
public fun <D : CallableDescriptor, F : D> performResolutionForCandidateCall(
|
||||||
context: CallCandidateResolutionContext<D>,
|
context: CallCandidateResolutionContext<D>,
|
||||||
task: ResolutionTask<D, F>
|
checkArguments: CheckArgumentTypesMode
|
||||||
): Unit = with(context) {
|
): Unit = with(context) {
|
||||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||||
|
|
||||||
@@ -79,7 +78,7 @@ public class CandidateResolver(
|
|||||||
|
|
||||||
checkVisibility()
|
checkVisibility()
|
||||||
|
|
||||||
when (task.checkArguments) {
|
when (checkArguments) {
|
||||||
CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS ->
|
CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS ->
|
||||||
mapArguments()
|
mapArguments()
|
||||||
CheckArgumentTypesMode.CHECK_CALLABLE_TYPE ->
|
CheckArgumentTypesMode.CHECK_CALLABLE_TYPE ->
|
||||||
|
|||||||
+29
-23
@@ -19,11 +19,13 @@ package org.jetbrains.kotlin.resolve.calls.results;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||||
|
import org.jetbrains.kotlin.resolve.BindingTrace;
|
||||||
import org.jetbrains.kotlin.resolve.OverrideResolver;
|
import org.jetbrains.kotlin.resolve.OverrideResolver;
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||||
|
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext;
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode;
|
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.MutableResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionTask;
|
import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
@@ -42,10 +44,11 @@ public class ResolutionResultsHandler {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeResultAndReportErrors(
|
public <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeResultAndReportErrors(
|
||||||
@NotNull ResolutionTask task,
|
@NotNull CallResolutionContext context,
|
||||||
|
@NotNull TracingStrategy tracing,
|
||||||
@NotNull Collection<MutableResolvedCall<D>> candidates
|
@NotNull Collection<MutableResolvedCall<D>> candidates
|
||||||
) {
|
) {
|
||||||
boolean resolveOverloads = task.checkArguments == CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS; // todo rename CheckArgumentTypesMode
|
boolean resolveOverloads = context.checkArguments == CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS; // todo rename CheckArgumentTypesMode
|
||||||
|
|
||||||
Set<MutableResolvedCall<D>> successfulCandidates = Sets.newLinkedHashSet();
|
Set<MutableResolvedCall<D>> successfulCandidates = Sets.newLinkedHashSet();
|
||||||
Set<MutableResolvedCall<D>> failedCandidates = Sets.newLinkedHashSet();
|
Set<MutableResolvedCall<D>> failedCandidates = Sets.newLinkedHashSet();
|
||||||
@@ -70,22 +73,23 @@ public class ResolutionResultsHandler {
|
|||||||
// TODO : maybe it's better to filter overrides out first, and only then look for the maximally specific
|
// TODO : maybe it's better to filter overrides out first, and only then look for the maximally specific
|
||||||
|
|
||||||
if (!successfulCandidates.isEmpty() || !incompleteCandidates.isEmpty()) {
|
if (!successfulCandidates.isEmpty() || !incompleteCandidates.isEmpty()) {
|
||||||
return computeSuccessfulResult(task, successfulCandidates, incompleteCandidates, resolveOverloads);
|
return computeSuccessfulResult(context, tracing, successfulCandidates, incompleteCandidates, resolveOverloads);
|
||||||
}
|
}
|
||||||
else if (!failedCandidates.isEmpty()) {
|
else if (!failedCandidates.isEmpty()) {
|
||||||
return computeFailedResult(task, failedCandidates, resolveOverloads);
|
return computeFailedResult(tracing, context.trace, failedCandidates, resolveOverloads);
|
||||||
}
|
}
|
||||||
if (!candidatesWithWrongReceiver.isEmpty()) {
|
if (!candidatesWithWrongReceiver.isEmpty()) {
|
||||||
task.tracing.unresolvedReferenceWrongReceiver(task.trace, candidatesWithWrongReceiver);
|
tracing.unresolvedReferenceWrongReceiver(context.trace, candidatesWithWrongReceiver);
|
||||||
return OverloadResolutionResultsImpl.candidatesWithWrongReceiver(candidatesWithWrongReceiver);
|
return OverloadResolutionResultsImpl.candidatesWithWrongReceiver(candidatesWithWrongReceiver);
|
||||||
}
|
}
|
||||||
task.tracing.unresolvedReference(task.trace);
|
tracing.unresolvedReference(context.trace);
|
||||||
return OverloadResolutionResultsImpl.nameNotFound();
|
return OverloadResolutionResultsImpl.nameNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeSuccessfulResult(
|
private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeSuccessfulResult(
|
||||||
@NotNull ResolutionTask task,
|
@NotNull CallResolutionContext context,
|
||||||
|
@NotNull TracingStrategy tracing,
|
||||||
@NotNull Set<MutableResolvedCall<D>> successfulCandidates,
|
@NotNull Set<MutableResolvedCall<D>> successfulCandidates,
|
||||||
@NotNull Set<MutableResolvedCall<D>> incompleteCandidates,
|
@NotNull Set<MutableResolvedCall<D>> incompleteCandidates,
|
||||||
boolean resolveOverloads
|
boolean resolveOverloads
|
||||||
@@ -96,23 +100,23 @@ public class ResolutionResultsHandler {
|
|||||||
OverloadResolutionResultsImpl<D> results = chooseAndReportMaximallySpecific(successfulAndIncomplete, true, resolveOverloads);
|
OverloadResolutionResultsImpl<D> results = chooseAndReportMaximallySpecific(successfulAndIncomplete, true, resolveOverloads);
|
||||||
if (results.isSingleResult()) {
|
if (results.isSingleResult()) {
|
||||||
MutableResolvedCall<D> resultingCall = results.getResultingCall();
|
MutableResolvedCall<D> resultingCall = results.getResultingCall();
|
||||||
resultingCall.getTrace().moveAllMyDataTo(task.trace);
|
resultingCall.getTrace().moveAllMyDataTo(context.trace);
|
||||||
if (resultingCall.getStatus() == INCOMPLETE_TYPE_INFERENCE) {
|
if (resultingCall.getStatus() == INCOMPLETE_TYPE_INFERENCE) {
|
||||||
return OverloadResolutionResultsImpl.incompleteTypeInference(resultingCall);
|
return OverloadResolutionResultsImpl.incompleteTypeInference(resultingCall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (results.isAmbiguity()) {
|
if (results.isAmbiguity()) {
|
||||||
task.tracing.recordAmbiguity(task.trace, results.getResultingCalls());
|
tracing.recordAmbiguity(context.trace, results.getResultingCalls());
|
||||||
boolean allCandidatesIncomplete = allIncomplete(results.getResultingCalls());
|
boolean allCandidatesIncomplete = allIncomplete(results.getResultingCalls());
|
||||||
// This check is needed for the following case:
|
// This check is needed for the following case:
|
||||||
// x.foo(unresolved) -- if there are multiple foo's, we'd report an ambiguity, and it does not make sense here
|
// x.foo(unresolved) -- if there are multiple foo's, we'd report an ambiguity, and it does not make sense here
|
||||||
if (task.checkArguments != CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS ||
|
if (context.checkArguments != CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS ||
|
||||||
!CallUtilKt.hasUnresolvedArguments(task.call, task)) {
|
!CallUtilKt.hasUnresolvedArguments(context.call, context)) {
|
||||||
if (allCandidatesIncomplete) {
|
if (allCandidatesIncomplete) {
|
||||||
task.tracing.cannotCompleteResolve(task.trace, results.getResultingCalls());
|
tracing.cannotCompleteResolve(context.trace, results.getResultingCalls());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
task.tracing.ambiguity(task.trace, results.getResultingCalls());
|
tracing.ambiguity(context.trace, results.getResultingCalls());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (allCandidatesIncomplete) {
|
if (allCandidatesIncomplete) {
|
||||||
@@ -124,7 +128,8 @@ public class ResolutionResultsHandler {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeFailedResult(
|
private <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> computeFailedResult(
|
||||||
@NotNull ResolutionTask task,
|
@NotNull TracingStrategy tracing,
|
||||||
|
@NotNull BindingTrace trace,
|
||||||
@NotNull Set<MutableResolvedCall<D>> failedCandidates,
|
@NotNull Set<MutableResolvedCall<D>> failedCandidates,
|
||||||
boolean resolveOverloads
|
boolean resolveOverloads
|
||||||
) {
|
) {
|
||||||
@@ -141,34 +146,35 @@ public class ResolutionResultsHandler {
|
|||||||
}
|
}
|
||||||
if (!thisLevel.isEmpty()) {
|
if (!thisLevel.isEmpty()) {
|
||||||
if (severityLevel.contains(ARGUMENTS_MAPPING_ERROR)) {
|
if (severityLevel.contains(ARGUMENTS_MAPPING_ERROR)) {
|
||||||
return recordFailedInfo(task, thisLevel);
|
return recordFailedInfo(tracing, trace, thisLevel);
|
||||||
}
|
}
|
||||||
OverloadResolutionResultsImpl<D> results = chooseAndReportMaximallySpecific(thisLevel, false, resolveOverloads);
|
OverloadResolutionResultsImpl<D> results = chooseAndReportMaximallySpecific(thisLevel, false, resolveOverloads);
|
||||||
return recordFailedInfo(task, results.getResultingCalls());
|
return recordFailedInfo(tracing, trace, results.getResultingCalls());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert false : "Should not be reachable, cause every status must belong to some level";
|
assert false : "Should not be reachable, cause every status must belong to some level";
|
||||||
|
|
||||||
Set<MutableResolvedCall<D>> noOverrides = OverrideResolver.filterOutOverridden(failedCandidates, MAP_TO_CANDIDATE);
|
Set<MutableResolvedCall<D>> noOverrides = OverrideResolver.filterOutOverridden(failedCandidates, MAP_TO_CANDIDATE);
|
||||||
return recordFailedInfo(task, noOverrides);
|
return recordFailedInfo(tracing, trace, noOverrides);
|
||||||
}
|
}
|
||||||
|
|
||||||
return recordFailedInfo(task, failedCandidates);
|
return recordFailedInfo(tracing, trace, failedCandidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> recordFailedInfo(
|
private static <D extends CallableDescriptor> OverloadResolutionResultsImpl<D> recordFailedInfo(
|
||||||
@NotNull ResolutionTask task,
|
@NotNull TracingStrategy tracing,
|
||||||
|
@NotNull BindingTrace trace,
|
||||||
@NotNull Collection<MutableResolvedCall<D>> candidates
|
@NotNull Collection<MutableResolvedCall<D>> candidates
|
||||||
) {
|
) {
|
||||||
if (candidates.size() == 1) {
|
if (candidates.size() == 1) {
|
||||||
MutableResolvedCall<D> failed = candidates.iterator().next();
|
MutableResolvedCall<D> failed = candidates.iterator().next();
|
||||||
failed.getTrace().moveAllMyDataTo(task.trace);
|
failed.getTrace().moveAllMyDataTo(trace);
|
||||||
return OverloadResolutionResultsImpl.singleFailedCandidate(failed);
|
return OverloadResolutionResultsImpl.singleFailedCandidate(failed);
|
||||||
}
|
}
|
||||||
task.tracing.noneApplicable(task.trace, candidates);
|
tracing.noneApplicable(trace, candidates);
|
||||||
task.tracing.recordAmbiguity(task.trace, candidates);
|
tracing.recordAmbiguity(trace, candidates);
|
||||||
return OverloadResolutionResultsImpl.manyFailedCandidates(candidates);
|
return OverloadResolutionResultsImpl.manyFailedCandidates(candidates);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user