class Crystal::VirtualType
inherits Crystal::Type
¶
A virtual type represents a type or any of its subclasses. It's created automatically by the compiler when a type is used in a generic argument and it either has subtypes, or it's abstract. A virtual type never exists for a non-abstract type that doesn't have subtypes.
A virtual type is denoted, internally, with a '+' sign following the type.
class Foo
end
class Bar < Foo
end
# Here the compiler actually makes this be [] of Foo+, so the array
# can actually hold a Foo or a Bar, transparently.
ary = [] of Foo
# Here the compiler leaves it as [] of Bar, because Bar has no subclasses.
another = [] of Bar
Included modules
Crystal::ClassVarContainer
Crystal::DefInstanceContainer
Crystal::InstanceVarContainer
Crystal::MultiType
Crystal::VirtualTypeLookup
Class methods¶
Methods¶
#replace_type_parameters(instance)
¶
(instance)
Replace type parameters in this type with the type parameters of the given instance type.