abstract class Crystal::GenericInstanceType
inherits Crystal::Type
¶
An instantiated generic type (like Array(String) or Enumerable(Int32)).
To represent generic superclasses and generic included modules, GenericInstanceType is also used. For example, in:
class Foo(T); end
class Bar(T) < Foo(T); end
The GenericClassType Bar(T)
will have a GenericClassInstanceType
Foo(T)
as a superclass, with T
being a TypeParameter
. We can't
simply have the generic type Foo(T)
be the superclass (maybe in this
particular example yes) but we could also have:
class Foo(X, Y); end
class Bar(T) < Foo(Int32, T); end
In that case Foo(X, Y)
is not quite the superclass, because
the superclass has a fixed type Int32
as the first parameter.
Direct known subclasses
Crystal::GenericClassInstanceType
Crystal::GenericModuleInstanceType
Class methods¶
Methods¶
#class_var_owner
¶
Returns the type that owns class vars for a type.
This method returns self, but subclasses might override. For example, a metaclass' class_var_owner is the instance type.
#lookup_path_item(name : String, lookup_in_namespace, include_private, location)
¶
(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.
#replace_type_parameters(instance)
¶
(instance)
Replace type parameters in this type with the type parameters of the given instance type.