コード例 #1
0
  @Nullable
  private ResolvedCall<FunctionDescriptor> getResolvedCallForFunction(
      @NotNull Call call,
      @NotNull JetExpression callExpression,
      @NotNull ReceiverValue receiver,
      @NotNull ResolutionContext context,
      @NotNull ResolveMode resolveMode,
      @NotNull boolean[] result) {

    CallResolver callResolver = expressionTypingServices.getCallResolver();
    OverloadResolutionResults<FunctionDescriptor> results =
        callResolver.resolveFunctionCall(
            BasicCallResolutionContext.create(context, call, resolveMode));
    if (!results.isNothing()) {
      checkSuper(receiver, results, context.trace, callExpression);
      result[0] = true;
      if (results.isSingleResult() && resolveMode == ResolveMode.TOP_LEVEL_CALL) {
        if (CallResolverUtil.hasReturnTypeDependentOnNotInferredParams(
            results.getResultingCall())) {
          return null;
        }
      }
      return results.isSingleResult() ? results.getResultingCall() : null;
    }
    result[0] = false;
    return null;
  }
コード例 #2
0
  @Nullable
  private JetType getVariableType(
      @NotNull JetSimpleNameExpression nameExpression,
      @NotNull ReceiverValue receiver,
      @Nullable ASTNode callOperationNode,
      @NotNull ResolutionContext context,
      @NotNull boolean[] result) {
    TemporaryBindingTrace traceForVariable =
        TemporaryBindingTrace.create(
            context.trace, "trace to resolve as local variable or property", nameExpression);
    CallResolver callResolver = expressionTypingServices.getCallResolver();
    Call call = CallMaker.makePropertyCall(receiver, callOperationNode, nameExpression);
    OverloadResolutionResults<VariableDescriptor> resolutionResult =
        callResolver.resolveSimpleProperty(
            BasicCallResolutionContext.create(
                context.replaceBindingTrace(traceForVariable),
                call,
                ResolveMode.TOP_LEVEL_CALL,
                ResolutionResultsCache.create()));
    if (!resolutionResult.isNothing()) {
      traceForVariable.commit();
      checkSuper(receiver, resolutionResult, context.trace, nameExpression);
      result[0] = true;
      return resolutionResult.isSingleResult()
          ? resolutionResult.getResultingDescriptor().getReturnType()
          : null;
    }

    ResolutionContext newContext =
        receiver.exists() ? context.replaceScope(receiver.getType().getMemberScope()) : context;
    TemporaryBindingTrace traceForNamespaceOrClassObject =
        TemporaryBindingTrace.create(
            context.trace, "trace to resolve as namespace or class object", nameExpression);
    JetType jetType =
        lookupNamespaceOrClassObject(
            nameExpression, newContext.replaceBindingTrace(traceForNamespaceOrClassObject));
    if (jetType != null) {
      traceForNamespaceOrClassObject.commit();

      // Uncommitted changes in temp context
      context.trace.record(RESOLUTION_SCOPE, nameExpression, context.scope);
      if (context.dataFlowInfo.hasTypeInfoConstraints()) {
        context.trace.record(
            NON_DEFAULT_EXPRESSION_DATA_FLOW, nameExpression, context.dataFlowInfo);
      }
      result[0] = true;
      return jetType;
    }
    result[0] = false;
    return null;
  }