public static Map<PsiElement, @Nls String> checkReturnTypeCompatible(PsiLambdaExpression lambdaExpression, PsiType functionalInterfaceReturnType) {
    Map<PsiElement, @Nls String> errors = new LinkedHashMap<>();
    if (PsiTypes.voidType().equals(functionalInterfaceReturnType)) {
      final PsiElement body = lambdaExpression.getBody();
      if (body instanceof PsiCodeBlock) {
        for (PsiExpression expression : getReturnExpressions(lambdaExpression)) {
          errors.put(expression, JavaPsiBundle.message("unexpected.return.value"));
        }
      }
      else if (body instanceof PsiExpression) {
        try {
          if (!PsiUtil.isStatement(JavaPsiFacade.getElementFactory(body.getProject()).createStatementFromText(body.getText(), body))) {
            final PsiType type = ((PsiExpression)body).getType();
            if (PsiTypes.voidType().equals(type)) {
              errors.put(body, JavaPsiBundle.message("lambda.body.must.be.a.statement.expression"));
            }
            else {
              errors.put(body, JavaPsiBundle.message("bad.return.type.in.lambda.expression1",
                                                     (type == PsiTypes.nullType() || type == null ? "<null>" : type.getPresentableText())));
            }
          }
        }
        catch (IncorrectOperationException ignore) {
        }
      }
    }
    else if (functionalInterfaceReturnType != null) {
      final List<PsiExpression> returnExpressions = getReturnExpressions(lambdaExpression);
      for (final PsiExpression expression : returnExpressions) {
        final PsiType expressionType = expression.getType();
        if (expressionType != null && !functionalInterfaceReturnType.isAssignableFrom(expressionType)) {
          errors.put(expression, JavaPsiBundle.message("bad.return.type.in.lambda.expression", expressionType.getPresentableText(),
                                                       functionalInterfaceReturnType.getPresentableText()));
        }
      }
      final PsiReturnStatement[] returnStatements = getReturnStatements(lambdaExpression);
      if (returnStatements.length > returnExpressions.size()) {
        for (PsiReturnStatement statement : returnStatements) {
          final PsiExpression value = statement.getReturnValue();
          if (value == null) {
            errors.put(statement, JavaPsiBundle.message("missing.return.value.lambda"));
          }
        }
      }
      else if (returnExpressions.isEmpty() && !lambdaExpression.isVoidCompatible()) {
        errors.put(lambdaExpression, JavaPsiBundle.message("missing.return.value.lambda"));
      }
    }
    return errors.isEmpty() ? null : errors;
  }
public static Map<PsiElement, @Nls String> checkReturnTypeCompatible(PsiLambdaExpression lambdaExpression, PsiType functionalInterfaceReturnType)