Ejemplo n.º 1
0
  private <D extends CallableDescriptor>
      OverloadResolutionResultsImpl<D> completeTypeInferenceDependentOnExpectedType(
          @NotNull BasicCallResolutionContext context,
          @NotNull OverloadResolutionResultsImpl<D> results,
          @NotNull TracingStrategy tracing) {
    if (results.isSingleResult()) {
      argumentTypeResolver.checkUnmappedArgumentTypes(
          context,
          results
              .getResultingCall()
              .getCallToCompleteTypeArgumentInference()
              .getUnmappedArguments());
    }

    if (!results.isSingleResult()) return results;

    ResolvedCallImpl<D> resolvedCall =
        results.getResultingCall().getCallToCompleteTypeArgumentInference();

    if (!resolvedCall.hasIncompleteTypeParameters()) {
      CallCandidateResolutionContext<D> callCandidateResolutionContext =
          CallCandidateResolutionContext.createForCallBeingAnalyzed(resolvedCall, context, tracing);
      candidateResolver.completeNestedCallsInference(callCandidateResolutionContext);
      candidateResolver.checkValueArgumentTypes(callCandidateResolutionContext);
      return results;
    }
    ResolvedCallImpl<D> copy = CallResolverUtil.copy(resolvedCall, context);
    CallCandidateResolutionContext<D> callCandidateResolutionContext =
        CallCandidateResolutionContext.createForCallBeingAnalyzed(copy, context, tracing);
    candidateResolver.completeTypeInferenceDependentOnExpectedTypeForCall(
        callCandidateResolutionContext, false);

    if (copy.getStatus().isSuccess()) {
      return OverloadResolutionResultsImpl.success(copy);
    }
    return OverloadResolutionResultsImpl.incompleteTypeInference(copy);
  }
Ejemplo n.º 2
0
 @NotNull
 private CallTranslator finish() {
   if (resolvedCall == null) {
     assert descriptor != null;
     resolvedCall =
         ResolvedCallImpl.create(
             ResolutionCandidate.create(
                 descriptor,
                 DescriptorUtils.safeGetValue(descriptor.getExpectedThisObject()),
                 DescriptorUtils.safeGetValue(descriptor.getReceiverParameter()),
                 ExplicitReceiverKind.THIS_OBJECT,
                 false),
             TemporaryBindingTrace.create(
                 new BindingTraceContext(), "trace to resolve call (in js)"));
   }
   if (descriptor == null) {
     descriptor = resolvedCall.getCandidateDescriptor().getOriginal();
   }
   assert resolvedCall != null;
   return new CallTranslator(receiver, callee, args, resolvedCall, descriptor, callType, context);
 }