コード例 #1
0
  @NotNull
  public KotlinType getBodyExpressionType(
      @NotNull BindingTrace trace,
      @NotNull LexicalScope outerScope,
      @NotNull DataFlowInfo dataFlowInfo,
      @NotNull KtDeclarationWithBody function,
      @NotNull FunctionDescriptor functionDescriptor) {
    KtExpression bodyExpression = function.getBodyExpression();
    assert bodyExpression != null;
    LexicalScope functionInnerScope =
        FunctionDescriptorUtil.getFunctionInnerScope(outerScope, functionDescriptor, trace);

    ExpressionTypingContext context =
        ExpressionTypingContext.newContext(
            trace, functionInnerScope, dataFlowInfo, NO_EXPECTED_TYPE);
    KotlinTypeInfo typeInfo =
        expressionTypingFacade.getTypeInfo(bodyExpression, context, function.hasBlockBody());

    KotlinType type = typeInfo.getType();
    if (type != null) {
      return type;
    } else {
      return ErrorUtils.createErrorType("Error function type");
    }
  }
コード例 #2
0
  /*package*/ void checkFunctionReturnType(
      KtDeclarationWithBody function, ExpressionTypingContext context) {
    KtExpression bodyExpression = function.getBodyExpression();
    if (bodyExpression == null) return;

    boolean blockBody = function.hasBlockBody();
    ExpressionTypingContext newContext =
        blockBody ? context.replaceExpectedType(NO_EXPECTED_TYPE) : context;

    expressionTypingFacade.getTypeInfo(bodyExpression, newContext, blockBody);
  }
コード例 #3
0
 @NotNull
 public KotlinTypeInfo getTypeInfo(
     @NotNull LexicalScope scope,
     @NotNull KtExpression expression,
     @NotNull KotlinType expectedType,
     @NotNull DataFlowInfo dataFlowInfo,
     @NotNull BindingTrace trace,
     boolean isStatement) {
   ExpressionTypingContext context =
       ExpressionTypingContext.newContext(trace, scope, dataFlowInfo, expectedType);
   return expressionTypingFacade.getTypeInfo(expression, context, isStatement);
 }
コード例 #4
0
 @NotNull
 public KotlinTypeInfo getTypeInfo(
     @NotNull KtExpression expression, @NotNull ResolutionContext resolutionContext) {
   return expressionTypingFacade.getTypeInfo(
       expression, ExpressionTypingContext.newContext(resolutionContext));
 }