CommonProblemDescriptor[] ( @NotNull RefEntity refEntity, @NotNull AnalysisScope scope, @NotNull InspectionManager manager, @NotNull GlobalInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor processor) { if (!(refEntity instanceof RefMethod refMethod)) { return null; } //don't warn on overriders if (refMethod.hasSuperMethods()) { return null; } PsiElement element = refMethod.getPsiElement(); if (!(element instanceof PsiMethod psiMethod)) { return null; } if (psiMethod.getBody() == null && refMethod.getDerivedReferences().isEmpty()) { return null; } final Set<RefOverridable> allScopeInheritors = MethodInheritanceUtils.calculateSiblingReferences(refMethod); for (RefOverridable siblingReference : allScopeInheritors) { PsiElement psi = siblingReference.getPsiElement(); if (psi instanceof PsiMethod siblingPsiMethod) { if (siblingPsiMethod.getBody() != null && !alwaysReturnsConstant(siblingPsiMethod.getBody())) { return null; } } else if (psi instanceof PsiLambdaExpression siblingLambda) { if (siblingLambda.getBody() != null && !alwaysReturnsConstant(siblingLambda)) { return null; } } else if (psi instanceof PsiMethodReferenceExpression) { return null; } } for (RefOverridable siblingReference : allScopeInheritors) { PsiElement psi = siblingReference.getPsiElement(); if (!(psi instanceof PsiMethod siblingMethod)) continue; final PsiIdentifier identifier = siblingMethod.getNameIdentifier(); if (identifier == null) { continue; } processor.addProblemElement(siblingReference, manager.createProblemDescriptor(identifier, InspectionGadgetsBundle.message( "method.return.always.constant.problem.descriptor"), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } return null; }