rename CallResolutionContext to CallCandidateResolutionContext

This commit is contained in:
Svetlana Isakova
2013-01-25 17:34:38 +04:00
parent 97e1f0ba3c
commit 87a6be6749
4 changed files with 30 additions and 30 deletions
@@ -25,12 +25,12 @@ import org.jetbrains.jet.lang.resolve.calls.tasks.ResolutionTask;
import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy; import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy;
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue;
public final class CallResolutionContext<D extends CallableDescriptor, F extends D> extends ResolutionContext { public final class CallCandidateResolutionContext<D extends CallableDescriptor, F extends D> extends ResolutionContext {
/*package*/ final ResolvedCallImpl<D> candidateCall; /*package*/ final ResolvedCallImpl<D> candidateCall;
/*package*/ final TracingStrategy tracing; /*package*/ final TracingStrategy tracing;
/*package*/ ReceiverValue receiverForVariableAsFunctionSecondCall = ReceiverValue.NO_RECEIVER; /*package*/ ReceiverValue receiverForVariableAsFunctionSecondCall = ReceiverValue.NO_RECEIVER;
private CallResolutionContext( private CallCandidateResolutionContext(
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace,
@NotNull TracingStrategy tracing, @NotNull Call call, boolean namespacesAllowed @NotNull TracingStrategy tracing, @NotNull Call call, boolean namespacesAllowed
) { ) {
@@ -40,7 +40,7 @@ public final class CallResolutionContext<D extends CallableDescriptor, F extends
this.candidateCall.setInitialDataFlowInfo(dataFlowInfo); this.candidateCall.setInitialDataFlowInfo(dataFlowInfo);
} }
private CallResolutionContext( private CallCandidateResolutionContext(
@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, @NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing,
@NotNull ResolvedCallImpl<D> candidateCall @NotNull ResolvedCallImpl<D> candidateCall
) { ) {
@@ -50,21 +50,21 @@ public final class CallResolutionContext<D extends CallableDescriptor, F extends
this.candidateCall.setInitialDataFlowInfo(dataFlowInfo); this.candidateCall.setInitialDataFlowInfo(dataFlowInfo);
} }
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create( public static <D extends CallableDescriptor, F extends D> CallCandidateResolutionContext<D, F> create(
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace,
@NotNull TracingStrategy tracing, @NotNull Call call) { @NotNull TracingStrategy tracing, @NotNull Call call) {
return new CallResolutionContext<D, F>(candidateCall, task, trace, tracing, call, task.namespacesAllowed); return new CallCandidateResolutionContext<D, F>(candidateCall, task, trace, tracing, call, task.namespacesAllowed);
} }
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create( public static <D extends CallableDescriptor, F extends D> CallCandidateResolutionContext<D, F> create(
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace,
@NotNull TracingStrategy tracing) { @NotNull TracingStrategy tracing) {
return create(candidateCall, task, trace, tracing, task.call); return create(candidateCall, task, trace, tracing, task.call);
} }
public static <D extends CallableDescriptor> CallResolutionContext<D, D> create( public static <D extends CallableDescriptor> CallCandidateResolutionContext<D, D> create(
@NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing, @NotNull BasicResolutionContext context, @NotNull TracingStrategy tracing,
@NotNull ResolvedCallImpl<D> candidateCall) { @NotNull ResolvedCallImpl<D> candidateCall) {
return new CallResolutionContext<D, D>(context, tracing, candidateCall); return new CallCandidateResolutionContext<D, D>(context, tracing, candidateCall);
} }
} }
@@ -321,7 +321,7 @@ public class CallResolver {
ResolvedCallWithTrace<D> maximallySpecific = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(incompleteCalls, false); ResolvedCallWithTrace<D> maximallySpecific = OverloadingConflictResolver.INSTANCE.findMaximallySpecific(incompleteCalls, false);
if (maximallySpecific != null) { if (maximallySpecific != null) {
candidateResolver.completeTypeInferenceDependentOnExpectedTypeForCall( candidateResolver.completeTypeInferenceDependentOnExpectedTypeForCall(
CallResolutionContext.create(context, tracing, (ResolvedCallImpl<D>) maximallySpecific)); CallCandidateResolutionContext.create(context, tracing, (ResolvedCallImpl<D>) maximallySpecific));
for (ResolvedCallWithTrace<D> callWithUnknownTypeParameters : incompleteCalls) { for (ResolvedCallWithTrace<D> callWithUnknownTypeParameters : incompleteCalls) {
if (callWithUnknownTypeParameters != maximallySpecific) { if (callWithUnknownTypeParameters != maximallySpecific) {
((ResolvedCallImpl<D>) callWithUnknownTypeParameters).addStatus(ResolutionStatus.OTHER_ERROR); ((ResolvedCallImpl<D>) callWithUnknownTypeParameters).addStatus(ResolutionStatus.OTHER_ERROR);
@@ -499,8 +499,8 @@ public class CallResolver {
for (ResolutionCandidate<D> resolutionCandidate : task.getCandidates()) { for (ResolutionCandidate<D> resolutionCandidate : task.getCandidates()) {
TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create( TemporaryBindingTrace candidateTrace = TemporaryBindingTrace.create(
task.trace, "trace to resolve candidate"); task.trace, "trace to resolve candidate");
Collection<CallResolutionContext<D, F>> contexts = callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace); Collection<CallCandidateResolutionContext<D, F>> contexts = callTransformer.createCallContexts(resolutionCandidate, task, candidateTrace);
for (CallResolutionContext<D, F> context : contexts) { for (CallCandidateResolutionContext<D, F> context : contexts) {
candidateResolver.performResolutionForCandidateCall(context, task); candidateResolver.performResolutionForCandidateCall(context, task);
@@ -62,24 +62,24 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
* Returns two contexts for 'variable as function' case (in FUNCTION_CALL_TRANSFORMER), one context otherwise * Returns two contexts for 'variable as function' case (in FUNCTION_CALL_TRANSFORMER), one context otherwise
*/ */
@NotNull @NotNull
public Collection<CallResolutionContext<D, F>> createCallContexts(@NotNull ResolutionCandidate<D> candidate, public Collection<CallCandidateResolutionContext<D, F>> createCallContexts(@NotNull ResolutionCandidate<D> candidate,
@NotNull ResolutionTask<D, F> task, @NotNull ResolutionTask<D, F> task,
@NotNull TemporaryBindingTrace candidateTrace) { @NotNull TemporaryBindingTrace candidateTrace) {
ResolvedCallImpl<D> candidateCall = ResolvedCallImpl.create(candidate, candidateTrace); ResolvedCallImpl<D> candidateCall = ResolvedCallImpl.create(candidate, candidateTrace);
return Collections.singleton(CallResolutionContext.create(candidateCall, task, candidateTrace, task.tracing)); return Collections.singleton(CallCandidateResolutionContext.create(candidateCall, task, candidateTrace, task.tracing));
} }
/** /**
* Returns collection of resolved calls for 'invoke' for 'variable as function' case (in FUNCTION_CALL_TRANSFORMER), * Returns collection of resolved calls for 'invoke' for 'variable as function' case (in FUNCTION_CALL_TRANSFORMER),
* the resolved call from callResolutionContext otherwise * the resolved call from callCandidateResolutionContext otherwise
*/ */
@NotNull @NotNull
public Collection<ResolvedCallWithTrace<F>> transformCall(@NotNull CallResolutionContext<D, F> callResolutionContext, public Collection<ResolvedCallWithTrace<F>> transformCall(@NotNull CallCandidateResolutionContext<D, F> callCandidateResolutionContext,
@NotNull CallResolver callResolver, @NotNull CallResolver callResolver,
@NotNull ResolutionTask<D, F> task) { @NotNull ResolutionTask<D, F> task) {
return Collections.singleton((ResolvedCallWithTrace<F>)callResolutionContext.candidateCall); return Collections.singleton((ResolvedCallWithTrace<F>) callCandidateResolutionContext.candidateCall);
} }
@@ -88,7 +88,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
public static CallTransformer<CallableDescriptor, FunctionDescriptor> FUNCTION_CALL_TRANSFORMER = new CallTransformer<CallableDescriptor, FunctionDescriptor>() { public static CallTransformer<CallableDescriptor, FunctionDescriptor> FUNCTION_CALL_TRANSFORMER = new CallTransformer<CallableDescriptor, FunctionDescriptor>() {
@NotNull @NotNull
@Override @Override
public Collection<CallResolutionContext<CallableDescriptor, FunctionDescriptor>> createCallContexts(@NotNull ResolutionCandidate<CallableDescriptor> candidate, public Collection<CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor>> createCallContexts(@NotNull ResolutionCandidate<CallableDescriptor> candidate,
@NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task, @NotNull TemporaryBindingTrace candidateTrace) { @NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task, @NotNull TemporaryBindingTrace candidateTrace) {
if (candidate.getDescriptor() instanceof FunctionDescriptor) { if (candidate.getDescriptor() instanceof FunctionDescriptor) {
@@ -100,18 +100,18 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
boolean hasReceiver = candidate.getReceiverArgument().exists(); boolean hasReceiver = candidate.getReceiverArgument().exists();
Call variableCall = stripCallArguments(task); Call variableCall = stripCallArguments(task);
if (!hasReceiver) { if (!hasReceiver) {
CallResolutionContext<CallableDescriptor, FunctionDescriptor> context = CallResolutionContext.create( CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor> context = CallCandidateResolutionContext.create(
ResolvedCallImpl.create(candidate, candidateTrace), task, candidateTrace, task.tracing, variableCall); ResolvedCallImpl.create(candidate, candidateTrace), task, candidateTrace, task.tracing, variableCall);
return Collections.singleton(context); return Collections.singleton(context);
} }
Call variableCallWithoutReceiver = stripReceiver(variableCall); Call variableCallWithoutReceiver = stripReceiver(variableCall);
CallResolutionContext<CallableDescriptor, FunctionDescriptor> contextWithReceiver = createContextWithChainedTrace( CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor> contextWithReceiver = createContextWithChainedTrace(
candidate, variableCall, candidateTrace, task); candidate, variableCall, candidateTrace, task);
ResolutionCandidate<CallableDescriptor> candidateWithoutReceiver = ResolutionCandidate.create( ResolutionCandidate<CallableDescriptor> candidateWithoutReceiver = ResolutionCandidate.create(
candidate.getDescriptor(), candidate.getThisObject(), ReceiverValue.NO_RECEIVER, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, false); candidate.getDescriptor(), candidate.getThisObject(), ReceiverValue.NO_RECEIVER, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, false);
CallResolutionContext<CallableDescriptor, FunctionDescriptor> contextWithoutReceiver = createContextWithChainedTrace( CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor> contextWithoutReceiver = createContextWithChainedTrace(
candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task); candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task);
contextWithoutReceiver.receiverForVariableAsFunctionSecondCall = variableCall.getExplicitReceiver(); contextWithoutReceiver.receiverForVariableAsFunctionSecondCall = variableCall.getExplicitReceiver();
@@ -119,12 +119,12 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver); return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver);
} }
private CallResolutionContext<CallableDescriptor, FunctionDescriptor> createContextWithChainedTrace(ResolutionCandidate<CallableDescriptor> candidate, private CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor> createContextWithChainedTrace(ResolutionCandidate<CallableDescriptor> candidate,
Call call, TemporaryBindingTrace temporaryTrace, ResolutionTask<CallableDescriptor, FunctionDescriptor> task) { Call call, TemporaryBindingTrace temporaryTrace, ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
ChainedTemporaryBindingTrace chainedTrace = ChainedTemporaryBindingTrace.create(temporaryTrace, "chained trace to resolve candidate", candidate); ChainedTemporaryBindingTrace chainedTrace = ChainedTemporaryBindingTrace.create(temporaryTrace, "chained trace to resolve candidate", candidate);
ResolvedCallImpl<CallableDescriptor> resolvedCall = ResolvedCallImpl.create(candidate, chainedTrace); ResolvedCallImpl<CallableDescriptor> resolvedCall = ResolvedCallImpl.create(candidate, chainedTrace);
return CallResolutionContext.create(resolvedCall, task, chainedTrace, task.tracing, call); return CallCandidateResolutionContext.create(resolvedCall, task, chainedTrace, task.tracing, call);
} }
private Call stripCallArguments(@NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task) { private Call stripCallArguments(@NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
@@ -171,7 +171,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
@NotNull @NotNull
@Override @Override
public Collection<ResolvedCallWithTrace<FunctionDescriptor>> transformCall(@NotNull final CallResolutionContext<CallableDescriptor, FunctionDescriptor> context, public Collection<ResolvedCallWithTrace<FunctionDescriptor>> transformCall(@NotNull final CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor> context,
@NotNull CallResolver callResolver, @NotNull final ResolutionTask<CallableDescriptor, FunctionDescriptor> task) { @NotNull CallResolver callResolver, @NotNull final ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
final CallableDescriptor descriptor = context.candidateCall.getCandidateDescriptor(); final CallableDescriptor descriptor = context.candidateCall.getCandidateDescriptor();
@@ -205,7 +205,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
}); });
} }
private Call createFunctionCall(final CallResolutionContext<CallableDescriptor, FunctionDescriptor> context, private Call createFunctionCall(final CallCandidateResolutionContext<CallableDescriptor, FunctionDescriptor> context,
final ResolutionTask<CallableDescriptor, FunctionDescriptor> task, JetType returnType) { final ResolutionTask<CallableDescriptor, FunctionDescriptor> task, JetType returnType) {
final ExpressionReceiver receiverFromVariable = new ExpressionReceiver(task.reference, returnType); final ExpressionReceiver receiverFromVariable = new ExpressionReceiver(task.reference, returnType);
@@ -62,7 +62,7 @@ public class CandidateResolver {
} }
public <D extends CallableDescriptor, F extends D> void performResolutionForCandidateCall( public <D extends CallableDescriptor, F extends D> void performResolutionForCandidateCall(
@NotNull CallResolutionContext<D, F> context, @NotNull CallCandidateResolutionContext<D, F> context,
@NotNull ResolutionTask<D, F> task) { @NotNull ResolutionTask<D, F> task) {
ProgressIndicatorProvider.checkCanceled(); ProgressIndicatorProvider.checkCanceled();
@@ -163,7 +163,7 @@ public class CandidateResolver {
AutoCastUtils.recordAutoCastIfNecessary(candidateCall.getThisObject(), candidateCall.getTrace()); AutoCastUtils.recordAutoCastIfNecessary(candidateCall.getThisObject(), candidateCall.getTrace());
} }
private static boolean checkOuterClassMemberIsAccessible(@NotNull CallResolutionContext<?, ?> context) { private static boolean checkOuterClassMemberIsAccessible(@NotNull CallCandidateResolutionContext<?, ?> context) {
// In "this@Outer.foo()" the error will be reported on "this@Outer" instead // In "this@Outer.foo()" the error will be reported on "this@Outer" instead
if (context.call.getExplicitReceiver().exists()) return true; if (context.call.getExplicitReceiver().exists()) return true;
@@ -182,7 +182,7 @@ public class CandidateResolver {
} }
public <D extends CallableDescriptor> void completeTypeInferenceDependentOnExpectedTypeForCall( public <D extends CallableDescriptor> void completeTypeInferenceDependentOnExpectedTypeForCall(
CallResolutionContext<D, D> context CallCandidateResolutionContext<D, D> context
) { ) {
ResolvedCallImpl<D> resolvedCall = context.candidateCall; ResolvedCallImpl<D> resolvedCall = context.candidateCall;
assert resolvedCall.hasUnknownTypeParameters(); assert resolvedCall.hasUnknownTypeParameters();
@@ -257,7 +257,7 @@ public class CandidateResolver {
} }
} }
private <D extends CallableDescriptor, F extends D> ResolutionStatus inferTypeArguments(CallResolutionContext<D, F> context) { private <D extends CallableDescriptor, F extends D> ResolutionStatus inferTypeArguments(CallCandidateResolutionContext<D, F> context) {
ResolvedCallImpl<D> candidateCall = context.candidateCall; ResolvedCallImpl<D> candidateCall = context.candidateCall;
final D candidate = candidateCall.getCandidateDescriptor(); final D candidate = candidateCall.getCandidateDescriptor();
@@ -372,7 +372,7 @@ public class CandidateResolver {
} }
private <D extends CallableDescriptor, F extends D> ValueArgumentsCheckingResult checkAllValueArguments( private <D extends CallableDescriptor, F extends D> ValueArgumentsCheckingResult checkAllValueArguments(
@NotNull CallResolutionContext<D, F> context, @NotNull CallCandidateResolutionContext<D, F> context,
@NotNull ResolveMode resolveFunctionArgumentBodies) { @NotNull ResolveMode resolveFunctionArgumentBodies) {
ValueArgumentsCheckingResult checkingResult = checkValueArgumentTypes(context, context.candidateCall, ValueArgumentsCheckingResult checkingResult = checkValueArgumentTypes(context, context.candidateCall,
context.candidateCall.getTrace(), resolveFunctionArgumentBodies); context.candidateCall.getTrace(), resolveFunctionArgumentBodies);
@@ -462,7 +462,7 @@ public class CandidateResolver {
return null; return null;
} }
private <D extends CallableDescriptor, F extends D> ResolutionStatus checkReceiver(CallResolutionContext<D, F> context, ResolvedCall<D> candidateCall, private <D extends CallableDescriptor, F extends D> ResolutionStatus checkReceiver(CallCandidateResolutionContext<D, F> context, ResolvedCall<D> candidateCall,
ReceiverParameterDescriptor receiverParameter, ReceiverValue receiverArgument, ReceiverParameterDescriptor receiverParameter, ReceiverValue receiverArgument,
boolean isExplicitReceiver, boolean implicitInvokeCheck) { boolean isExplicitReceiver, boolean implicitInvokeCheck) {