def _infer_common_type(irs: typing.List[irast.Base], schema):
    if (not irs):
        raise ql_errors.EdgeQLError('cannot determine common type of an empty set', context=irs[0].context)
    col_type = None
    arg_types = []
    empties = []
    for (i, arg) in enumerate(irs):
        if (isinstance(arg, irast.EmptySet) and (arg.scls is None)):
            empties.append(i)
            continue
        arg_type = infer_type(arg, schema)
        arg_types.append(arg_type)
        if isinstance(arg_type, s_types.Collection):
            col_type = arg_type
    if (not arg_types):
        raise ql_errors.EdgeQLError('cannot determine common type of an empty set', context=irs[0].context)
    if (col_type is not None):
        if (not all((col_type.issubclass(t) for t in arg_types))):
            raise ql_errors.EdgeQLError('cannot determine common type', context=irs[0].context)
        common_type = col_type
    else:
        common_type = s_utils.get_class_nearest_common_ancestor(arg_types)
    for i in empties:
        amend_empty_set_type(irs[i], common_type, schema)
    return common_type
def _infer_common_type(irs: typing.List[irast.Base], schema):
    if (not irs):
        raise ql_errors.EdgeQLError('cannot determine common type of an empty set', context=irs[0].context)
    col_type = None
    arg_types = []
    empties = []
    for (i, arg) in enumerate(irs):
        if (isinstance(arg, irast.EmptySet) and (arg.scls is None)):
            empties.append(i)
            continue
        arg_type = infer_type(arg, schema)
        arg_types.append(arg_type)
        if isinstance(arg_type, s_types.Collection):
            col_type = arg_type
    if (not arg_types):
        raise ql_errors.EdgeQLError('cannot determine common type of an empty set', context=irs[0].context)
    if (col_type is not None):
        if (not all((col_type.issubclass(t) for t in arg_types))):
            raise ql_errors.EdgeQLError('cannot determine common type', context=irs[0].context)
        common_type = col_type
    else:
        common_type = s_utils.get_class_nearest_common_ancestor(arg_types)
    for i in empties:
        amend_empty_set_type(irs[i], common_type, schema)
    return common_type