Refactoring: made explicitExtensionReceiverForInvoke final

This commit is contained in:
Svetlana Isakova
2014-03-17 20:48:47 +04:00
parent f311da3f8f
commit 8f269f1806
2 changed files with 26 additions and 14 deletions
@@ -21,6 +21,7 @@ import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
@@ -109,28 +110,27 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
ResolvedCallImpl.create(candidate, candidateTrace, task.tracing, task.dataFlowInfoForArguments), task, candidateTrace, task.tracing, variableCall);
return Collections.singleton(context);
}
Call variableCallWithoutReceiver = stripReceiver(variableCall);
CallCandidateResolutionContext<CallableDescriptor> contextWithReceiver = createContextWithChainedTrace(
candidate, variableCall, candidateTrace, task);
candidate, variableCall, candidateTrace, task, ReceiverValue.NO_RECEIVER);
Call variableCallWithoutReceiver = stripReceiver(variableCall);
ResolutionCandidate<CallableDescriptor> candidateWithoutReceiver = ResolutionCandidate.create(
candidate.getCall(), candidate.getDescriptor(), candidate.getThisObject(), ReceiverValue.NO_RECEIVER,
ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, false);
CallCandidateResolutionContext<CallableDescriptor> contextWithoutReceiver = createContextWithChainedTrace(
candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task);
contextWithoutReceiver.explicitExtensionReceiverForInvoke = variableCall.getExplicitReceiver();
candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task, variableCall.getExplicitReceiver());
return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver);
}
private CallCandidateResolutionContext<CallableDescriptor> createContextWithChainedTrace(ResolutionCandidate<CallableDescriptor> candidate,
Call call, TemporaryBindingTrace temporaryTrace, ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
private CallCandidateResolutionContext<CallableDescriptor> createContextWithChainedTrace(
@NotNull ResolutionCandidate<CallableDescriptor> candidate, @NotNull Call call, @NotNull TemporaryBindingTrace temporaryTrace,
@NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task, @NotNull ReceiverValue receiverValue
) {
ChainedTemporaryBindingTrace chainedTrace = ChainedTemporaryBindingTrace.create(temporaryTrace, "chained trace to resolve candidate", candidate);
ResolvedCallImpl<CallableDescriptor> resolvedCall = ResolvedCallImpl.create(candidate, chainedTrace, task.tracing, task.dataFlowInfoForArguments);
return CallCandidateResolutionContext.create(resolvedCall, task, chainedTrace, task.tracing, call);
return CallCandidateResolutionContext.create(resolvedCall, task, chainedTrace, task.tracing, call, receiverValue);
}
private Call stripCallArguments(@NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task) {
@@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.types.expressions.LabelResolver;
public final class CallCandidateResolutionContext<D extends CallableDescriptor> extends CallResolutionContext<CallCandidateResolutionContext<D>> {
public final ResolvedCallImpl<D> candidateCall;
public final TracingStrategy tracing;
public ReceiverValue explicitExtensionReceiverForInvoke = ReceiverValue.NO_RECEIVER;
public final ReceiverValue explicitExtensionReceiverForInvoke;
private CallCandidateResolutionContext(
@NotNull ResolvedCallImpl<D> candidateCall,
@@ -50,23 +50,33 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
@NotNull LabelResolver labelResolver,
@Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments,
@NotNull CallResolverExtension callResolverExtension,
@NotNull ReceiverValue explicitExtensionReceiverForInvoke,
boolean isAnnotationContext
) {
super(trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, resolutionResultsCache, labelResolver,
dataFlowInfoForArguments, callResolverExtension, isAnnotationContext);
this.candidateCall = candidateCall;
this.tracing = tracing;
this.explicitExtensionReceiverForInvoke = explicitExtensionReceiverForInvoke;
}
public static <D extends CallableDescriptor> CallCandidateResolutionContext<D> create(
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull CallResolutionContext<?> context, @NotNull BindingTrace trace,
@NotNull TracingStrategy tracing, @NotNull Call call) {
@NotNull TracingStrategy tracing, @NotNull Call call, @NotNull ReceiverValue explicitExtensionReceiverForInvoke
) {
candidateCall.setInitialDataFlowInfo(context.dataFlowInfo);
return new CallCandidateResolutionContext<D>(
candidateCall, tracing, trace, context.scope, call, context.expectedType,
context.dataFlowInfo, context.contextDependency, context.checkArguments,
context.resolutionResultsCache, context.labelResolver, context.dataFlowInfoForArguments,
context.callResolverExtension, context.isAnnotationContext);
context.callResolverExtension, explicitExtensionReceiverForInvoke, context.isAnnotationContext);
}
public static <D extends CallableDescriptor> CallCandidateResolutionContext<D> create(
@NotNull ResolvedCallImpl<D> candidateCall, @NotNull CallResolutionContext<?> context, @NotNull BindingTrace trace,
@NotNull TracingStrategy tracing, @NotNull Call call
) {
return create(candidateCall, context, trace, tracing, call, ReceiverValue.NO_RECEIVER);
}
public static <D extends CallableDescriptor> CallCandidateResolutionContext<D> create(
@@ -81,7 +91,8 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
return new CallCandidateResolutionContext<D>(
candidateCall, tracing, context.trace, context.scope, context.call, context.expectedType,
context.dataFlowInfo, context.contextDependency, context.checkArguments, context.resolutionResultsCache,
context.labelResolver, context.dataFlowInfoForArguments, context.callResolverExtension, context.isAnnotationContext);
context.labelResolver, context.dataFlowInfoForArguments, context.callResolverExtension, ReceiverValue.NO_RECEIVER,
context.isAnnotationContext);
}
@Override
@@ -96,6 +107,7 @@ public final class CallCandidateResolutionContext<D extends CallableDescriptor>
) {
return new CallCandidateResolutionContext<D>(
candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments,
resolutionResultsCache, labelResolver, dataFlowInfoForArguments, callResolverExtension, isAnnotationContext);
resolutionResultsCache, labelResolver, dataFlowInfoForArguments, callResolverExtension, explicitExtensionReceiverForInvoke,
isAnnotationContext);
}
}