コード例 #1
0
ファイル: CallTransformer.java プロジェクト: JetXing/kotlin
 public CallForImplicitInvoke(
     @NotNull ReceiverValue explicitExtensionReceiver,
     @NotNull ExpressionReceiver calleeExpressionAsDispatchReceiver,
     @NotNull Call call) {
   super(call);
   this.outerCall = call;
   this.explicitExtensionReceiver = explicitExtensionReceiver;
   this.calleeExpressionAsDispatchReceiver = calleeExpressionAsDispatchReceiver;
   this.fakeInvokeExpression =
       (JetSimpleNameExpression)
           JetPsiFactory(call.getCallElement())
               .createExpression(OperatorConventions.INVOKE.asString());
 }
コード例 #2
0
ファイル: CallTransformer.java プロジェクト: JetXing/kotlin
        @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);
        }