def compile_Introspect(expr: qlast.Introspect, *, ctx: context.ContextLevel) -> irast.Set: typeref = typegen.ql_typeexpr_to_ir_typeref(expr.type, ctx=ctx) if typeref.material_type and not irtyputils.is_object(typeref): typeref = typeref.material_type if typeref.is_opaque_union: typeref = typegen.type_to_typeref( typing.cast( s_objtypes.ObjectType, ctx.env.schema.get('std::BaseObject'), ), env=ctx.env, ) if irtyputils.is_view(typeref): raise errors.QueryError(f'cannot introspect transient type variant', context=expr.type.context) if irtyputils.is_collection(typeref): raise errors.QueryError(f'cannot introspect collection types', context=expr.type.context) if irtyputils.is_generic(typeref): raise errors.QueryError(f'cannot introspect generic types', context=expr.type.context) return setgen.ensure_set(irast.TypeIntrospection(typeref=typeref), ctx=ctx)
def compile_Introspect(expr: qlast.Introspect, *, ctx: context.ContextLevel) -> irast.Base: typeref = typegen.ql_typeref_to_ir_typeref(expr.type, ctx=ctx) if typeref.material_type and not irtyputils.is_object(typeref): typeref = typeref.material_type if irtyputils.is_view(typeref): raise errors.QueryError(f'cannot introspect views', context=expr.type.context) if irtyputils.is_collection(typeref): raise errors.QueryError(f'cannot introspect collection types', context=expr.type.context) if irtyputils.is_generic(typeref): raise errors.QueryError(f'cannot introspect generic types', context=expr.type.context) return irast.TypeIntrospection(typeref=typeref)