PsiType[] (@NotNull PsiMethod method) { PsiType lub = null; boolean hasVoid = false; for (PsiReturnStatement statement : PsiUtil.findReturnStatements(method)) { PsiExpression value = statement.getReturnValue(); if (value == null) { hasVoid = true; } else { PsiType type = value.getType(); if (lub == null) { lub = type; } else if (type != null) { lub = GenericsUtil.getLeastUpperBound(lub, type, method.getManager()); } } } if (hasVoid && lub == null) { lub = PsiTypes.voidType(); } if (lub instanceof PsiIntersectionType) { return ((PsiIntersectionType)lub).getConjuncts(); } return lub == null ? PsiType.EMPTY_ARRAY : new PsiType[]{lub}; }