receiver for second ('invoke') call for 'variable as function' call case added to context

This commit is contained in:
Svetlana Isakova
2012-04-30 15:34:18 +04:00
parent 24082a67d7
commit a8f959fee8
2 changed files with 12 additions and 6 deletions
@@ -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<D extends CallableDescriptor> extends ResolutionContext {
public final class CallResolutionContext<D extends CallableDescriptor, F extends D> extends ResolutionContext {
/*package*/ final ResolvedCallImpl<D> candidateCall;
/*package*/ final TracingStrategy tracing;
/*package*/ ReceiverDescriptor receiverForVariableAsFunctionSecondCall = ReceiverDescriptor.NO_RECEIVER;
public CallResolutionContext(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) {
private CallResolutionContext(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> 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<D> candidateCall, @NotNull ResolutionTask<D> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) {
this(candidateCall, task, trace, tracing, task.call);
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing, @NotNull Call call) {
return new CallResolutionContext<D, F>(candidateCall, task, trace, tracing, call);
}
public static <D extends CallableDescriptor, F extends D> CallResolutionContext<D, F> create(@NotNull ResolvedCallImpl<D> candidateCall, @NotNull ResolutionTask<D, F> task, @NotNull BindingTrace trace, @NotNull TracingStrategy tracing) {
return create(candidateCall, task, trace, tracing, task.call);
}
}
@@ -106,7 +106,7 @@ public class CallTransformer<D extends CallableDescriptor, F extends D> {
CallResolutionContext<CallableDescriptor, FunctionDescriptor> 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<D extends CallableDescriptor, F extends D> {
@NotNull
@Override
public ReceiverDescriptor getExplicitReceiver() {
return context.delayedReceiverForVariableAsFunctionSecondCall;
return context.receiverForVariableAsFunctionSecondCall;
}
@NotNull