PsiType (@NotNull PsiMethod method) { PsiManager manager = method.getManager(); PsiReturnStatement[] returnStatements = PsiUtil.findReturnStatements(method); if (returnStatements.length == 0) return PsiTypes.voidType(); PsiType expectedType = null; for (PsiReturnStatement returnStatement : returnStatements) { ReturnModel returnModel = ReturnModel.create(returnStatement); if (returnModel == null) return null; expectedType = lub(expectedType, returnModel.myLeastType, returnModel.myType, method, manager); } return expectedType; }