@_infer_type.register(irast.TypeRef)
def __infer_typeref(ir, schema):
    if ir.subtypes:
        coll = s_types.Collection.get_class(ir.maintype)
        result = coll.from_subtypes([infer_type(t, schema) for t in ir.subtypes])
    else:
        result = schema.get(ir.maintype)
    return result
@_infer_type.register(irast.TypeRef)
def __infer_typeref(ir, schema):
    if ir.subtypes:
        coll = s_types.Collection.get_class(ir.maintype)
        result = coll.from_subtypes([infer_type(t, schema) for t in ir.subtypes])
    else:
        result = schema.get(ir.maintype)
    return result