reflect.Union
A union-kind view of a `type` value. Users never construct this class.
Signature
class reflect.UnionA union-kind view of a type value. Users never construct this class.
Source:<builtin>/reflect/kinds.bamlbytes 6738–7861
Fields
_ty
reflect.TypeThe wrapped type value. Private by invariant: reflection natives are
its only readers, and each kind method panics if the held type no longer
classifies as this view's kind.
Static methods
(internal) Internal native backing new; every member is a type
value.
Constructs the canonical union of types.
Throws
reflect.errors.CompilationErrorif the members cannot form a union.
Instance methods
The union's members, in canonical order.
Implementations
reflect.AnyClass for T
Instance methods
The class declaration's schema metadata, or empty metadata when the runtime type is not a class.
Read the field called name as T, or null if this value's class
declares no such field. A present field holding null also reads as
null; use has_field or get<T?> to tell the two apart.
Throws
reflect.errors.TypeMismatchif the field's value is not aT.
A value-bound handle to the field called name, or null if this
value's class declares no such field.
get
<T>(self, name: string) -> T throws reflect.errors.NotFound | reflect.errors.TypeMismatchRead the field called name as T. Read a nullable field with a
nullable T (get<int?>). find returns null for a missing field
instead of throwing.
Throws
reflect.errors.NotFoundif this value's class declares no field calledname.reflect.errors.TypeMismatchif the field's value is not aT.
A value-bound handle to the field called name. find_field returns
null instead of throwing.
Throws
reflect.errors.NotFoundif this value's class declares no field calledname.
has_field
(self, name: string) -> bool throws neverWhether this value's runtime class declares a field called name.
false when the runtime type is not a class.
Reflected fields bound to this value for Field.value<T>().
name
(self) -> string throws neverThe rendered name of this value's concrete runtime type.
This value's concrete runtime type.
Source:<builtin>/reflect/reflect.bamlbytes 14431–14461
reflect.TypeView for reflect.Union
Instance methods
Construct an array type whose element is this type.
Reverse of implements: iface.implemented_by(t) is the same as
t.implements(iface). false when this type is not an interface, or
when other is not a concrete type.
True iff this type nominally implements the interface other. Any
concrete type can: a class, an enum, a primitive, a list, a map, ...
other pins the interface's associated types (an omitted one takes
its default), and only an implementation with exactly those matches:
see reflect.Type.implements. false when other is not an
interface, or when this type is not a concrete type.
Returns the precise kind view of this type value.
meta
(Pair this type value with schema metadata without changing its identity.
optional
(self) -> reflect.Union throws neverConstruct the canonical union of this type and null.
Render deterministic canonical BAML source for this definition. Non-equivalent declarations with the same display name are rejected.
Source:<builtin>/reflect/kinds.bamlbytes 7511–7681
Related definitions
reflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.AnyClassreflect.TypeViewreflect.TypeViewreflect.TypeViewreflect.TypeViewreflect.TypeViewreflect.TypeViewreflect.TypeViewreflect.AnyClassreflect.Arrayreflect.class.Fieldreflect.errors.CompilationErrorreflect.errors.NotFoundreflect.errors.TypeMismatchreflect.Metareflect.Typereflect.TypeKindreflect.TypeViewreflect.WithMeta