Пример #1
0
  private void checkValueParameter(
      @NotNull CallCheckerContext context,
      @NotNull CallableDescriptor targetDescriptor,
      @NotNull ValueArgument targetArgument,
      @NotNull ValueParameterDescriptor targetParameterDescriptor) {
    KtExpression argumentExpression = targetArgument.getArgumentExpression();
    if (argumentExpression == null) {
      return;
    }
    CallableDescriptor argumentCallee = getCalleeDescriptor(context, argumentExpression, false);

    if (argumentCallee != null && inlinableParameters.contains(argumentCallee)) {
      if (InlineUtil.isInline(targetDescriptor)
          && isInlinableParameter(targetParameterDescriptor)) {
        if (allowsNonLocalReturns(argumentCallee)
            && !allowsNonLocalReturns(targetParameterDescriptor)) {
          context
              .getTrace()
              .report(NON_LOCAL_RETURN_NOT_ALLOWED.on(argumentExpression, argumentExpression));
        } else {
          checkNonLocalReturn(context, argumentCallee, argumentExpression);
        }
      } else {
        context
            .getTrace()
            .report(USAGE_IS_NOT_INLINABLE.on(argumentExpression, argumentExpression, descriptor));
      }
    }
  }
Пример #2
0
  private void checkNonLocalReturn(
      @NotNull CallCheckerContext context,
      @NotNull CallableDescriptor inlinableParameterDescriptor,
      @NotNull KtExpression parameterUsage) {
    if (!allowsNonLocalReturns(inlinableParameterDescriptor)) return;

    if (!checkNonLocalReturnUsage(descriptor, parameterUsage, context.getResolutionContext())) {
      context.getTrace().report(NON_LOCAL_RETURN_NOT_ALLOWED.on(parameterUsage, parameterUsage));
    }
  }