void (@NotNull PsiReturnStatement statement) { super.visitStatement(statement); if (!hasErrorResults() && HighlightingFeature.ENHANCED_SWITCH.isAvailable(myFile)) { add(HighlightUtil.checkReturnFromSwitchExpr(statement)); } if (!hasErrorResults()) { try { PsiElement parent = PsiTreeUtil.getParentOfType(statement, PsiFile.class, PsiClassInitializer.class, PsiLambdaExpression.class, PsiMethod.class); HighlightInfo.Builder info; if (parent instanceof PsiMethod && JavaPsiRecordUtil.isCompactConstructor((PsiMethod)parent)) { info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(statement) .descriptionAndTooltip(JavaErrorBundle.message("record.compact.constructor.return")); } else { info = parent != null ? HighlightUtil.checkReturnStatementType(statement, parent) : null; 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) { } } }