boolean (PsiMethod method) { if (method == null) { return false; } if (!InheritanceUtil.isInheritorOrSelf(method.getContainingClass(), PsiUtil.resolveClassInClassTypeOnly(method.getReturnType()), true)) { return false; } final PsiStatement lastStatement = ControlFlowUtils.getLastStatementInBlock(method.getBody()); if (!(lastStatement instanceof PsiReturnStatement returnStatement)) { return false; } final PsiExpression returnValue = returnStatement.getReturnValue(); return returnValue instanceof PsiThisExpression; }