From 8f269f1806a7a79c1f6ef08d89d2944b11df0c30 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 17 Mar 2014 20:48:47 +0400 Subject: [PATCH] Refactoring: made explicitExtensionReceiverForInvoke final --- .../lang/resolve/calls/CallTransformer.java | 18 +++++++-------- .../CallCandidateResolutionContext.java | 22 ++++++++++++++----- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java index 03d80116c1e..45256146beb 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallTransformer.java @@ -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 { ResolvedCallImpl.create(candidate, candidateTrace, task.tracing, task.dataFlowInfoForArguments), task, candidateTrace, task.tracing, variableCall); return Collections.singleton(context); } - Call variableCallWithoutReceiver = stripReceiver(variableCall); CallCandidateResolutionContext contextWithReceiver = createContextWithChainedTrace( - candidate, variableCall, candidateTrace, task); + candidate, variableCall, candidateTrace, task, ReceiverValue.NO_RECEIVER); + Call variableCallWithoutReceiver = stripReceiver(variableCall); ResolutionCandidate candidateWithoutReceiver = ResolutionCandidate.create( candidate.getCall(), candidate.getDescriptor(), candidate.getThisObject(), ReceiverValue.NO_RECEIVER, ExplicitReceiverKind.NO_EXPLICIT_RECEIVER, false); CallCandidateResolutionContext contextWithoutReceiver = createContextWithChainedTrace( - candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task); - - contextWithoutReceiver.explicitExtensionReceiverForInvoke = variableCall.getExplicitReceiver(); + candidateWithoutReceiver, variableCallWithoutReceiver, candidateTrace, task, variableCall.getExplicitReceiver()); return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver); } - private CallCandidateResolutionContext createContextWithChainedTrace(ResolutionCandidate candidate, - Call call, TemporaryBindingTrace temporaryTrace, ResolutionTask task) { - + private CallCandidateResolutionContext createContextWithChainedTrace( + @NotNull ResolutionCandidate candidate, @NotNull Call call, @NotNull TemporaryBindingTrace temporaryTrace, + @NotNull ResolutionTask task, @NotNull ReceiverValue receiverValue + ) { ChainedTemporaryBindingTrace chainedTrace = ChainedTemporaryBindingTrace.create(temporaryTrace, "chained trace to resolve candidate", candidate); ResolvedCallImpl 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 task) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java index bc5febb5964..d44c0dea26d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/CallCandidateResolutionContext.java @@ -34,7 +34,7 @@ import org.jetbrains.jet.lang.types.expressions.LabelResolver; public final class CallCandidateResolutionContext extends CallResolutionContext> { public final ResolvedCallImpl candidateCall; public final TracingStrategy tracing; - public ReceiverValue explicitExtensionReceiverForInvoke = ReceiverValue.NO_RECEIVER; + public final ReceiverValue explicitExtensionReceiverForInvoke; private CallCandidateResolutionContext( @NotNull ResolvedCallImpl candidateCall, @@ -50,23 +50,33 @@ public final class CallCandidateResolutionContext @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 CallCandidateResolutionContext create( @NotNull ResolvedCallImpl 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( 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 CallCandidateResolutionContext create( + @NotNull ResolvedCallImpl 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 CallCandidateResolutionContext create( @@ -81,7 +91,8 @@ public final class CallCandidateResolutionContext return new CallCandidateResolutionContext( 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 ) { return new CallCandidateResolutionContext( candidateCall, tracing, trace, scope, call, expectedType, dataFlowInfo, contextDependency, checkArguments, - resolutionResultsCache, labelResolver, dataFlowInfoForArguments, callResolverExtension, isAnnotationContext); + resolutionResultsCache, labelResolver, dataFlowInfoForArguments, callResolverExtension, explicitExtensionReceiverForInvoke, + isAnnotationContext); } }