Trait kailua_types::ty::Union
[−]
[src]
pub trait Union<Other = Self> { type Output; fn union(
&self,
other: &Other,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Self::Output>; }
Any types that can produce a union type, which is a supertype of two input types.
Associated Types
type Output
A type of the resulting type.
Required Methods
fn union(
&self,
other: &Other,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Self::Output>
&self,
other: &Other,
explicit: bool,
ctx: &mut TypeContext
) -> TypeResult<Self::Output>
Calculates a union type of self
and other
, explicitly or implicitly.
Kailua distinguishes two kinds of union types, explicitly constructed or not.
Explicitly constructed types are from the AST and should be retained as much as possible,
with a good fact that types constructible from the AST are limited and simpler.
3 | 4
is one such example.
Implicitly constructed types are used for or
operations or implicit return types,
and will use a much more coarse lattice than the explicit construction.
3 | 4
will result in integer
in this mode.
Because this is severely limited, the implicit union can only shrink the type's size.
Implementors
impl Union for Numbers
impl Union for Strings
impl Union for Tables
impl Union for Unioned
impl<'a> Union<Unioned> for T<'a>
impl<'a> Union<Ty> for T<'a>
impl<'a> Union<T<'a>> for Ty
impl Union<Ty> for Ty
impl Union for Slot
impl Union for TySeq
impl Union for SpannedTySeq
impl Union for SlotSeq
impl Union for SpannedSlotSeq
impl<A: Union<B>, B> Union<Box<B>> for Box<A>
impl<A, B> Union<Spanned<B>> for Spanned<A> where
A: Union<B>,