Example #1
0
  private static <F extends CallableDescriptor> void cacheResults(
      @NotNull ResolutionResultsCache.MemberType<F> memberType,
      @NotNull BasicCallResolutionContext context,
      @NotNull OverloadResolutionResultsImpl<F> results,
      @NotNull DelegatingBindingTrace traceToResolveCall,
      @NotNull TracingStrategy tracing) {
    CallKey callKey = CallResolverUtil.createCallKey(context);
    if (callKey == null) return;

    DelegatingBindingTrace deltasTraceToCacheResolve =
        new DelegatingBindingTrace(
            new BindingTraceContext().getBindingContext(),
            "delta trace for caching resolve of",
            context.call);
    traceToResolveCall.addAllMyDataTo(deltasTraceToCacheResolve);

    context.resolutionResultsCache.recordResolutionResults(callKey, memberType, results);
    context.resolutionResultsCache.recordResolutionTrace(callKey, deltasTraceToCacheResolve);

    if (results.isSingleResult() && memberType == ResolutionResultsCache.FUNCTION_MEMBER_TYPE) {
      CallCandidateResolutionContext<F> callCandidateResolutionContext =
          CallCandidateResolutionContext.createForCallBeingAnalyzed(
              results.getResultingCall().getCallToCompleteTypeArgumentInference(),
              context,
              tracing);
      context.resolutionResultsCache.recordDeferredComputationForCall(
          callKey, callCandidateResolutionContext, memberType);
    }
  }
Example #2
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);
  }
Example #3
0
 private <D extends CallableDescriptor> void completeTypeInferenceDependentOnFunctionLiterals(
     @NotNull BasicCallResolutionContext context,
     @NotNull OverloadResolutionResultsImpl<D> results,
     @NotNull TracingStrategy tracing) {
   if (!results.isSingleResult()) {
     if (results.getResultCode() == INCOMPLETE_TYPE_INFERENCE) {
       argumentTypeResolver.checkTypesWithNoCallee(context, RESOLVE_FUNCTION_ARGUMENTS);
     }
     return;
   }
   CallCandidateResolutionContext<D> candidateContext =
       CallCandidateResolutionContext.createForCallBeingAnalyzed(
           results.getResultingCall().getCallToCompleteTypeArgumentInference(), context, tracing);
   candidateResolver.completeTypeInferenceDependentOnFunctionLiteralsForCall(candidateContext);
 }