Beispiel #1
0
 /**
  * Returns two contexts for 'variable as function' case (in FUNCTION_CALL_TRANSFORMER), one
  * context otherwise
  */
 @NotNull
 public Collection<CallCandidateResolutionContext<D>> createCallContexts(
     @NotNull ResolutionCandidate<D> candidate,
     @NotNull ResolutionTask<D, F> task,
     @NotNull TemporaryBindingTrace candidateTrace,
     @NotNull CandidateResolveMode candidateResolveMode) {
   ResolvedCallImpl<D> candidateCall =
       ResolvedCallImpl.create(
           candidate, candidateTrace, task.tracing, task.dataFlowInfoForArguments);
   return Collections.singleton(
       CallCandidateResolutionContext.create(
           candidateCall,
           task,
           candidateTrace,
           task.tracing,
           task.call,
           ReceiverValue.NO_RECEIVER,
           candidateResolveMode));
 }
Beispiel #2
0
 private CallCandidateResolutionContext<CallableDescriptor> createContextWithChainedTrace(
     @NotNull ResolutionCandidate<CallableDescriptor> candidate,
     @NotNull Call call,
     @NotNull TemporaryBindingTrace temporaryTrace,
     @NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task,
     @NotNull ReceiverValue receiverValue,
     @NotNull CandidateResolveMode candidateResolveMode) {
   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,
       receiverValue,
       candidateResolveMode);
 }
Beispiel #3
0
        @NotNull
        @Override
        public Collection<CallCandidateResolutionContext<CallableDescriptor>> createCallContexts(
            @NotNull ResolutionCandidate<CallableDescriptor> candidate,
            @NotNull ResolutionTask<CallableDescriptor, FunctionDescriptor> task,
            @NotNull TemporaryBindingTrace candidateTrace,
            @NotNull CandidateResolveMode candidateResolveMode) {

          if (candidate.getDescriptor() instanceof FunctionDescriptor) {
            return super.createCallContexts(candidate, task, candidateTrace, candidateResolveMode);
          }

          assert candidate.getDescriptor() instanceof VariableDescriptor;

          boolean hasReceiver = candidate.getExtensionReceiver().exists();
          Call variableCall = stripCallArguments(task.call);
          ResolutionCandidate<CallableDescriptor> variableCandidate =
              ResolutionCandidate.create(
                  variableCall,
                  candidate.getDescriptor(),
                  candidate.getDispatchReceiver(),
                  candidate.getExtensionReceiver(),
                  candidate.getExplicitReceiverKind(),
                  null);
          if (!hasReceiver) {
            CallCandidateResolutionContext<CallableDescriptor> context =
                CallCandidateResolutionContext.create(
                    ResolvedCallImpl.create(
                        variableCandidate,
                        candidateTrace,
                        task.tracing,
                        task.dataFlowInfoForArguments),
                    task,
                    candidateTrace,
                    task.tracing,
                    variableCall,
                    ReceiverValue.NO_RECEIVER,
                    candidateResolveMode);
            return Collections.singleton(context);
          }
          CallCandidateResolutionContext<CallableDescriptor> contextWithReceiver =
              createContextWithChainedTrace(
                  variableCandidate,
                  variableCall,
                  candidateTrace,
                  task,
                  ReceiverValue.NO_RECEIVER,
                  candidateResolveMode);

          Call variableCallWithoutReceiver = stripReceiver(variableCall);
          ResolutionCandidate<CallableDescriptor> candidateWithoutReceiver =
              ResolutionCandidate.create(
                  variableCallWithoutReceiver,
                  candidate.getDescriptor(),
                  candidate.getDispatchReceiver(),
                  ReceiverValue.NO_RECEIVER,
                  ExplicitReceiverKind.NO_EXPLICIT_RECEIVER,
                  null);

          CallCandidateResolutionContext<CallableDescriptor> contextWithoutReceiver =
              createContextWithChainedTrace(
                  candidateWithoutReceiver,
                  variableCallWithoutReceiver,
                  candidateTrace,
                  task,
                  variableCall.getExplicitReceiver(),
                  candidateResolveMode);

          return Lists.newArrayList(contextWithReceiver, contextWithoutReceiver);
        }