Пример #1
0
  private <D extends CallableDescriptor, F extends D>
      OverloadResolutionResultsImpl<F> doResolveCallOrGetCachedResults(
          @NotNull ResolutionResultsCache.MemberType<F> memberType,
          @NotNull BasicCallResolutionContext context,
          @NotNull List<ResolutionTask<D, F>> prioritizedTasks,
          @NotNull CallTransformer<D, F> callTransformer,
          @NotNull JetReferenceExpression reference) {
    OverloadResolutionResultsImpl<F> results = null;
    TracingStrategy tracing =
        prioritizedTasks.isEmpty()
            ? TracingStrategy.EMPTY
            : prioritizedTasks.iterator().next().tracing;
    TemporaryBindingTrace traceToResolveCall =
        TemporaryBindingTrace.create(context.trace, "trace to resolve call", context.call);
    CallKey callKey = CallResolverUtil.createCallKey(context);
    if (callKey != null) {
      OverloadResolutionResultsImpl<F> cachedResults =
          context.resolutionResultsCache.getResolutionResults(callKey, memberType);
      if (cachedResults != null) {
        DelegatingBindingTrace deltasTraceForResolve =
            context.resolutionResultsCache.getResolutionTrace(callKey);
        assert deltasTraceForResolve != null;
        deltasTraceForResolve.addAllMyDataTo(traceToResolveCall);
        results = cachedResults;
      }
    }
    if (results == null) {
      BasicCallResolutionContext newContext = context.replaceBindingTrace(traceToResolveCall);
      results = doResolveCall(newContext, prioritizedTasks, callTransformer, reference);
      DelegatingBindingTrace deltasTraceForTypeInference =
          ((OverloadResolutionResultsImpl) results).getTrace();
      if (deltasTraceForTypeInference != null) {
        deltasTraceForTypeInference.addAllMyDataTo(traceToResolveCall);
      }
      completeTypeInferenceDependentOnFunctionLiterals(newContext, results, tracing);
      cacheResults(memberType, context, results, traceToResolveCall, tracing);
    }
    traceToResolveCall.commit();

    if (!prioritizedTasks.isEmpty() && context.contextDependency == ContextDependency.INDEPENDENT) {
      results = completeTypeInferenceDependentOnExpectedType(context, results, tracing);
    }

    if (extension != null) {
      extension.run(results, context);
    }

    return results;
  }
Пример #2
0
 @NotNull
 public OverloadResolutionResults<FunctionDescriptor> resolveFunctionCall(
     @NotNull BindingTrace trace,
     @NotNull JetScope scope,
     @NotNull Call call,
     @NotNull JetType expectedType,
     @NotNull DataFlowInfo dataFlowInfo) {
   return resolveFunctionCall(
       BasicCallResolutionContext.create(
           trace,
           scope,
           call,
           expectedType,
           dataFlowInfo,
           ContextDependency.INDEPENDENT,
           CheckValueArgumentsMode.ENABLED,
           ExpressionPosition.FREE,
           ResolutionResultsCacheImpl.create(),
           LabelResolver.create(),
           null));
 }
Пример #3
0
  public OverloadResolutionResults<FunctionDescriptor> resolveCallWithKnownCandidate(
      @NotNull Call call,
      @Nullable TracingStrategy tracing,
      @NotNull JetReferenceExpression reference,
      @NotNull ResolutionContext<?> context,
      @NotNull ResolutionCandidate<CallableDescriptor> candidate,
      @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments) {
    BasicCallResolutionContext basicCallResolutionContext =
        BasicCallResolutionContext.create(
            context, call, CheckValueArgumentsMode.ENABLED, dataFlowInfoForArguments);

    List<ResolutionTask<CallableDescriptor, FunctionDescriptor>> tasks =
        TaskPrioritizer
            .<CallableDescriptor, FunctionDescriptor>computePrioritizedTasksFromCandidates(
                basicCallResolutionContext, reference, Collections.singleton(candidate), tracing);
    return doResolveCallOrGetCachedResults(
        ResolutionResultsCache.FUNCTION_MEMBER_TYPE,
        basicCallResolutionContext,
        tasks,
        CallTransformer.FUNCTION_CALL_TRANSFORMER,
        reference);
  }