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

A type of the resulting type.

Required Methods

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