Skip to content

abstract class Crystal::UnionType
inherits Crystal::Type

Base class for instantiated union types.

Included modules

Crystal::MultiType

Direct known subclasses

Crystal::MixedUnionType Crystal::NilableProcType Crystal::NilableReferenceUnionType Crystal::NilableType Crystal::ReferenceUnionType

Class methods

.new(program, union_types)

View source

Methods

#all?

Yields self and returns true if the block returns a truthy value. UnionType overrides it and yields all types in turn and returns true if for each of them the block returns true.

View source

#append_cover(array)

View source

#cover

View source

#cover_size

View source

#each_concrete_type

View source

#each_cover

View source

#expand_union_types

View source

#filter_by_responds_to(name)

View source

#generic_nest

View source

#generic_type

View source

#implements?(other_type : Type)

View source

#includes_type?(other_type)

View source

#lookup_path_item(name : String, lookup_in_namespace, include_private, location)

Looks up a single path item relative to *self`.

If lookup_in_namespace is true, if the type is not found in self or self's parents, the path item is searched in this type's namespace. This parameter is useful because when writing Foo::Bar::Baz, Foo should be searched in enclosing namespaces, but Bar and Baz not.

View source

#metaclass

Returns this type's metaclass, which holds class methods for this type.

View source

#parents

View source

#replace_type_parameters(instance)

Replace type parameters in this type with the type parameters of the given instance type.

View source

#restrict(other : Metaclass, context)

View source

#restrict(other : Union, context)

View source

#restrict(other : Type, context)

View source

#restrict(other : ProcNotation, context)

View source

#restrict(other : Generic, context)

View source

#restrict_type_or_fun_or_generic(other, context)

View source

#restriction_of?(type, owner, strict = false)

View source

#superclass

Returns this type's superclass, or nil if it doesn't have one

View source

#to_s_with_options(io : IO, skip_union_parens : Bool = false, generic_args : Bool = true, codegen : Bool = false) : Nil

View source

#type_desc

View source

#union_types : Array(Type)

View source

#virtual_type

View source