int (@NotNull PyCallExpression callExpression, @NotNull PyResolveContext resolveContext, @NotNull TypeEvalContext evalContext) { final IntSummaryStatistics statistics = callExpression.multiResolveCalleeFunction(resolveContext) .stream() .map(callable -> callable.getCallType(evalContext, callExpression)) .collect( Collectors.summarizingInt( callType -> { if (callType instanceof PyNoneType) { return 1; } else if (callType instanceof PyClassType) { return countElements(evalContext, (PyClassType)callType); } else if (callType instanceof PyUnionType) { int maxNumber = 1; boolean allForSure = true; for (PyType member : ((PyUnionType)callType).getMembers()) { PyClassType classType = as(member, PyClassType.class); if (classType != null) { int elementsCount = countElements(evalContext, classType); allForSure = allForSure && elementsCount != -1; maxNumber = Math.max(maxNumber, elementsCount); } else { allForSure = false; } } return allForSure ? maxNumber : -1; } return -1; } ) ); if (statistics.getMin() == statistics.getMax()) { return statistics.getMin(); } else { return -1; } }