From a8f959fee828e72b389270fe695d2027690268e0 Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Mon, 30 Apr 2012 15:34:18 +0400 Subject: [PATCH] receiver for second ('invoke') call for 'variable as function' call case added to context --- .../lang/resolve/calls/CallResolutionContext.java | 14 ++++++++++---- .../jet/lang/resolve/calls/CallTransformer.java | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java index 03c5013330a..e5f8c356056 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolutionContext.java @@ -20,21 +20,27 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.psi.Call; import org.jetbrains.jet.lang.resolve.BindingTrace; +import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor; /** * @author svtk */ -public final class CallResolutionContext extends ResolutionContext { +public final class CallResolutionContext extends ResolutionContext { /*package*/ final ResolvedCallImpl candidateCall; /*package*/ final TracingStrategy tracing; + /*package*/ ReceiverDescriptor receiverForVariableAsFunctionSecondCall = ReceiverDescriptor.NO_RECEIVER; - public CallResolutionContext(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) { + private CallResolutionContext(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) { super(trace, task.scope, call, task.expectedType, task.dataFlowInfo); this.candidateCall = candidateCall; this.tracing = tracing; } - public CallResolutionContext(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) { - this(candidateCall, task, trace, tracing, task.call); + public static CallResolutionContext create(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) { + return new CallResolutionContext(candidateCall, task, trace, tracing, call); + } + + public static CallResolutionContext create(@NotNull ResolvedCallImpl candidateCall, @NotNull ResolutionTask task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) { + return create(candidateCall, task, trace, tracing, task.call); } } 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 adda74ced5e..63486dee599 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 @@ -106,7 +106,7 @@ public class CallTransformer { CallResolutionContext contextWithoutReceiver = createContextWithChainedTrace( candidateWithoutReceiver, variableCallWithoutReceiver, temporaryTrace, task); - contextWithoutReceiver.delayedReceiverForVariableAsFunctionSecondCall = variableCall.getExplicitReceiver(); + contextWithoutReceiver.receiverForVariableAsFunctionSecondCall = variableCall.getExplicitReceiver(); return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver); } @@ -207,7 +207,7 @@ public class CallTransformer { @NotNull @Override public ReceiverDescriptor getExplicitReceiver() { - return context.delayedReceiverForVariableAsFunctionSecondCall; + return context.receiverForVariableAsFunctionSecondCall; } @NotNull