@Override
  public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
    super.visitStatement(statement);
    if (!hasErrorResults() && PsiUtil.isAvailable(JavaFeature.ENHANCED_SWITCH, myFile)) {
      add(HighlightUtil.checkReturnFromSwitchExpr(statement));
    }
    if (!hasErrorResults()) {
      try {
        PsiElement parent = PsiTreeUtil.getParentOfType(statement, PsiFile.class, PsiClassInitializer.class,
                                                        PsiLambdaExpression.class, PsiMethod.class);
        if (parent instanceof PsiMethod method ) {
          if (JavaPsiRecordUtil.isCompactConstructor(method)) {
            add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement)
                  .descriptionAndTooltip(JavaErrorBundle.message("record.compact.constructor.return")));
          }
          else if (method.isConstructor()) {
            PsiMethodCallExpression constructorCall = JavaPsiConstructorUtil.findThisOrSuperCallInConstructor(method);
            if (constructorCall != null && statement.getTextOffset() < constructorCall.getTextOffset()) {
              add(HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement)
                    .descriptionAndTooltip(JavaErrorBundle.message("return.statement.not.allowed.before.explicit.constructor.call",
                                                                   constructorCall.getMethodExpression().getText() + "()")));
            }
          }
        }
        if (!hasErrorResults() && parent != null) {
          HighlightInfo.Builder info = HighlightUtil.checkReturnStatementType(statement, parent);
          if (info != null && parent instanceof PsiMethod method) {
            PsiType expectedType = myExpectedReturnTypes.computeIfAbsent(method, HighlightMethodUtil::determineReturnType);
            if (expectedType != null && !PsiTypes.voidType().equals(expectedType)) {
              HighlightUtil.registerReturnTypeFixes(info, method, expectedType);
            }
          }
          add(info);
        }
      }
      catch (IndexNotReadyException ignore) {
      }
    }
  }
@Override
  public void visitReturnStatement(@NotNull PsiReturnStatement statement)