class Crystal::TypeParameter
inherits Crystal::Type
¶
For example, given:
class Bar(T) < Foo(T, Int32)
end
when we solve Foo(T, Int32)
we'll find Foo, and
then instantiate it with T
being the type parameter
T
of Bar
, and Int32
a regular type variable.
Similarly, when including a generic module inside a generic type, type parameters will be used.
class Baz(T)
include Enumerable(T) # <- this is TypeParameter T of Foo
end
When instantiating Bar(T) in the first example, for example
doing Bar(Char)
, superclasses and including modules will
have type parameters replaced with types given in the instantiation,
so Foo(T, Int32)
will become Foo(Char, Int32)
.