class
Crystal::MetaclassType
- Crystal::MetaclassType
- Crystal::ClassType
- Crystal::ModuleType
- Crystal::NamedType
- Crystal::Type
- Reference
- Object
Overview
A metaclass type, that results from invoking .class on a type.
For example String.class is the metaclass of String, and it's
the type of String (the type of "foo" is String, the type of
String is String.class).
This metaclass represents only the metaclass of non-generic types.
Included Modules
Defined in:
compiler/crystal/semantic/path_lookup.crcompiler/crystal/semantic/restrictions.cr
compiler/crystal/semantic/suggestions.cr
compiler/crystal/types.cr
Constructors
Instance Method Summary
- #abstract?(*args, **options)
- #abstract?(*args, **options, &)
-
#class_var_owner
Returns the type that owns class vars for a type.
- #generic_nest(*args, **options)
- #generic_nest(*args, **options, &)
- #instance_type : Type
- #lookup_new_in_ancestors?(*args, **options)
- #lookup_new_in_ancestors?(*args, **options, &)
- #lookup_path(*args, **options)
- #lookup_path(*args, **options, &)
- #lookup_similar_path(*args, **options)
- #lookup_similar_path(*args, **options, &)
-
#metaclass
Returns this type's metaclass, which holds class methods for this type.
- #remove_typedef
-
#replace_type_parameters(instance)
Replace type parameters in this type with the type parameters of the given instance type.
- #restrict(other : Metaclass, context)
- #restrict(other : VirtualMetaclassType, context)
- #restriction_of?(other : VirtualMetaclassType, owner, self_free_vars = nil, other_free_vars = nil)
- #to_s_with_options(io : IO, skip_union_parens : Bool = false, generic_args : Bool = true, codegen : Bool = false) : Nil
- #type_desc
- #type_var?(*args, **options)
- #type_var?(*args, **options, &)
- #virtual_type
- #virtual_type!
Instance methods inherited from module Crystal::ClassVarContainer
class_vars
class_vars,
class_vars?
class_vars?,
lookup_class_var(name)
lookup_class_var,
lookup_class_var?(name)
lookup_class_var?
Instance methods inherited from class Crystal::ClassType
abstract=(abstract __arg0 : Bool)
abstract=,
abstract? : Bool
abstract?,
add_subclass(subclass)
add_subclass,
can_be_stored=(can_be_stored : Bool)
can_be_stored=,
can_be_stored? : Bool
can_be_stored?,
depth : Int32
depth,
extern=(extern : Bool)
extern=,
extern? : Bool
extern?,
extern_union=(extern_union : Bool)
extern_union=,
extern_union? : Bool
extern_union?,
force_add_subclass
force_add_subclass,
lookup_new_in_ancestors=(lookup_new_in_ancestors : Bool)
lookup_new_in_ancestors=,
lookup_new_in_ancestors? : Bool
lookup_new_in_ancestors?,
metaclass=(metaclass : Type | Nil)
metaclass=,
packed=(packed : Bool)
packed=,
packed? : Bool
packed?,
struct=(struct __arg0 : Bool)
struct=,
struct? : Bool
struct?,
subclasses : Array(Crystal::Type)
subclasses,
superclass : Type | Nil
superclass,
superclass=(superclass : Crystal::Type | Nil)
superclass=,
type_desc
type_desc
Constructor methods inherited from class Crystal::ClassType
new(program, namespace, name, superclass : Crystal::Type | Nil, add_subclass = true)
new
Instance methods inherited from module Crystal::InstanceVarInitializerContainer
add_instance_var_initializer(name, value, meta_vars)
add_instance_var_initializer,
get_instance_var_initializer(name)
get_instance_var_initializer,
has_instance_var_initializer?(name)
has_instance_var_initializer?,
instance_vars_initializers : Array(InstanceVarInitializer) | Nil
instance_vars_initializers
Instance methods inherited from module Crystal::SubclassObservable
add_subclass_observer(observer)
add_subclass_observer,
notify_subclass_added
notify_subclass_added,
remove_subclass_observer(observer)
remove_subclass_observer
Instance methods inherited from module Crystal::DefInstanceContainer
add_def_instance(key, typed_def)
add_def_instance,
def_instances
def_instances,
lookup_def_instance(key)
lookup_def_instance
Instance methods inherited from class Crystal::ModuleType
add_def(a_def)
add_def,
add_hook(kind : HookKind, a_macro, args_size = 0)
add_hook,
add_macro(a_macro)
add_macro,
defs : Hash(String, Array(DefWithMetadata)) | Nil
defs,
filter_by_responds_to(name)
filter_by_responds_to,
hooks : Array(Hook) | Nil
hooks,
include(mod)
include,
macros : Hash(String, Array(Macro)) | Nil
macros,
parents
parents,
type_desc
type_desc
Instance methods inherited from class Crystal::NamedType
add_location(location : Location)
add_location,
append_full_name(io : IO, codegen : Bool = false) : Nil
append_full_name,
doc : String | Nil
doc,
doc=(doc : String | Nil)
doc=,
full_name
full_name,
locations : Array(Location) | Nil
locations,
name : String
name,
namespace : ModuleType
namespace,
private=(private __arg0 : Bool)
private=,
private? : Bool
private?,
to_s_with_options(io : IO, skip_union_parens : Bool = false, generic_args : Bool = true, codegen : Bool = false) : Nil
to_s_with_options,
types
types,
types? : Hash(String, Crystal::NamedType)?
types?
Constructor methods inherited from class Crystal::NamedType
new(program, namespace : Crystal::ModuleType, name : String)
new
Instance methods inherited from class Crystal::Type
abstract?
abstract?,
abstract_leaf?
abstract_leaf?,
add_including_type(mod)
add_including_type,
add_instance_var_initializer(name, value, meta_vars)
add_instance_var_initializer,
add_subclass(subclass)
add_subclass,
all?(&)
all?,
all_class_vars
all_class_vars,
all_instance_vars
all_instance_vars,
all_instance_vars_count
all_instance_vars_count,
all_subclasses
all_subclasses,
allowed_in_lib?
allowed_in_lib?,
allows_instance_vars?
allows_instance_vars?,
ancestors
ancestors,
append_cover(array)
append_cover,
append_to_expand_union_types(types)
append_to_expand_union_types,
bool_type?
bool_type?,
can_be_stored?
can_be_stored?,
check_method_missing(signature, call)
check_method_missing,
check_restriction_exception
check_restriction_exception,
class?
class?,
class_var_owner
class_var_owner,
class_vars
class_vars,
compatible_with?(type)
compatible_with?,
cover
cover,
cover_size
cover_size,
declare_instance_var(name, type : Type, annotations = nil)
declare_instance_var,
define_method_from_method_missing(method_missing, signature, original_call)
define_method_from_method_missing,
defs : Hash(String, Array(DefWithMetadata)) | Nil
defs,
depth
depth,
devirtualize
devirtualize,
doc : String | Nil
doc,
double_variadic?
double_variadic?,
each_cover(&)
each_cover,
each_namespace(& : ModuleType -> ) : Nil
each_namespace,
extern?
extern?,
extern_union?
extern_union?,
ffi_arg_type : FFI::Type
ffi_arg_type,
ffi_type : FFI::Type
ffi_type,
filter_by(other_type : Type)
filter_by,
filter_by_responds_to(name)
filter_by_responds_to,
generic_nest
generic_nest,
generic_type
generic_type,
get_instance_var_initializer(name)
get_instance_var_initializer,
has_def?(name)
has_def?,
has_def_without_parents?(name)
has_def_without_parents?,
has_in_type_vars?(type)
has_in_type_vars?,
has_inner_pointers?
has_inner_pointers?,
has_instance_var_initializer?(name)
has_instance_var_initializer?,
has_protected_access_to?(type, allow_same_namespace = true)
has_protected_access_to?,
implements?(other_type : Type)
implements?,
implicitly_converted_in_c_to?(expected_type)
implicitly_converted_in_c_to?,
includes_type?(type)
includes_type?,
including_types
including_types,
index_of_instance_var(name)
index_of_instance_var,
inspect(io : IO) : Nil
inspect,
instance_type
instance_type,
instance_vars
instance_vars,
leaf?
leaf?,
llvm_name(io)llvm_name llvm_name, locations : Array(Location) | Nil locations, lookup_class_var(name) lookup_class_var, lookup_class_var?(name) lookup_class_var?, lookup_defs(name : String, lookup_ancestors_for_new : Bool = false)
lookup_defs(name : String, all_defs : Array(Def), lookup_ancestors_for_new : Bool | Nil = false) lookup_defs, lookup_defs_with_modules(name) lookup_defs_with_modules, lookup_defs_without_parents(name : String, all_defs : Array(Def))
lookup_defs_without_parents(name : String) lookup_defs_without_parents, lookup_first_def(name, block) lookup_first_def, lookup_instance_var(name : String)
lookup_instance_var(node : InstanceVar | ReadInstanceVar | MetaVar) lookup_instance_var, lookup_instance_var?(name : String) lookup_instance_var?, lookup_macro(name, args : Array, named_args) lookup_macro, lookup_macros(name) lookup_macros, lookup_matches(signature, owner = self, path_lookup = self, matches_array = nil, analyze_all = false) lookup_matches, lookup_matches_with_modules(signature, owner = self, path_lookup = self, matches_array = nil, analyze_all = false) lookup_matches_with_modules, lookup_matches_without_parents(signature, owner = self, path_lookup = self, matches_array = nil, analyze_all = false) lookup_matches_without_parents, lookup_method_missing lookup_method_missing, lookup_name(name) lookup_name, lookup_new_in_ancestors? lookup_new_in_ancestors?, lookup_path(path : Path, lookup_in_namespace = true, include_private = false, location = path.location) : Type | ASTNode | Nil
lookup_path(names : Array(String), lookup_in_namespace = true, include_private = false, location = nil) : Type | ASTNode | Nil lookup_path, lookup_path_item(name : String, lookup_self, lookup_in_namespace, include_private, location) : Type | ASTNode | Nil lookup_path_item, lookup_similar_def(name, args_size, block) lookup_similar_def, lookup_similar_def_name(name, args_size, block) lookup_similar_def_name, lookup_similar_instance_var_name(ivar_name : String)
lookup_similar_instance_var_name(name) lookup_similar_instance_var_name, lookup_similar_path(node : Path)
lookup_similar_path(names : Array(String), lookup_in_namespace = true) lookup_similar_path, lookup_type(node : ASTNode, self_type = self.instance_type, allow_typeof = true, free_vars : Hash(String, TypeVar) | Nil = nil, find_root_generic_type_parameters = true) : Type lookup_type, lookup_type?(node : ASTNode, self_type = self.instance_type, allow_typeof = true, free_vars : Hash(String, TypeVar) | Nil = nil, find_root_generic_type_parameters = true) : Type | Nil lookup_type?, lookup_type_var(node : Path, free_vars : Hash(String, TypeVar) | Nil = nil, find_root_generic_type_parameters = true, remove_alias = true) : Type | ASTNode lookup_type_var, lookup_type_var?(node : Path, free_vars : Hash(String, TypeVar) | Nil = nil, raise = false, find_root_generic_type_parameters = true) : Type | ASTNode | Nil lookup_type_var?, macros : Hash(String, Array(Macro)) | Nil macros, metaclass : Type metaclass, metaclass? metaclass?, module? module?, namespace : ModuleType namespace, nil_type? nil_type?, nilable? nilable?, no_return? no_return?, opaque_id opaque_id, packed? packed?, parents parents, passed_as_self? passed_as_self?, passed_by_value? passed_by_value?, pointer? pointer?, pretty_print(pp) pretty_print, private=(set_private) private=, private? private?, proc? proc?, program : Crystal::Program program, reference_like? reference_like?, remove_alias remove_alias, remove_alias_if_simple remove_alias_if_simple, remove_indirection remove_indirection, remove_literal remove_literal, remove_typedef remove_typedef, replace_type_parameters(instance) : Type replace_type_parameters, restrict(other : Nil, context)
restrict(other : AliasType, context)
restrict(other : UnionType, context)
restrict(other : VirtualType, context)
restrict(other : GenericClassType, context)
restrict(other : Type, context)
restrict(other : Self, context)
restrict(other : TypeOf, context)
restrict(other : Union, context)
restrict(other : Path, context)
restrict(other : Generic, context)
restrict(other : Metaclass, context)
restrict(other : ProcNotation, context)
restrict(other : Underscore, context)
restrict(other : Arg, context)
restrict(other : NumberLiteral, context)
restrict(other : Splat, context)
restrict(other : ASTNode, context) restrict, restriction_of?(other : UnionType, owner, self_free_vars = nil, other_free_vars = nil)
restriction_of?(other : VirtualType, owner, self_free_vars = nil, other_free_vars = nil)
restriction_of?(other : AliasType, owner, self_free_vars = nil, other_free_vars = nil)
restriction_of?(other : Type, owner, self_free_vars = nil, other_free_vars = nil)
restriction_of?(other : ASTNode, owner, self_free_vars = nil, other_free_vars = nil) restriction_of?, same_namespace?(other) same_namespace?, sizeof_type sizeof_type, splat_index splat_index, struct? struct?, subclasses : Array(Type) subclasses, superclass : Type | Nil superclass, to_s(io : IO) : Nil
to_s(*, generic_args : Bool = true) to_s, to_s_with_options(io : IO, skip_union_parens : Bool = false, generic_args : Bool = true, codegen : Bool = false) : Nil to_s_with_options, type_desc type_desc, type_var?(name) type_var?, type_vars type_vars, types types, types? types?, unbound? unbound?, virtual? virtual?, virtual_metaclass? virtual_metaclass?, virtual_type virtual_type, virtual_type! virtual_type!, void? void?
Constructor methods inherited from class Crystal::Type
merge!(type1 : Type, type2 : Type) : Typemerge!(types_or_nodes) : Type merge!, new(program : Program) new
Class methods inherited from class Crystal::Type
common_descendent(type1 : TupleInstanceType, type2 : TupleInstanceType)common_descendent(type1 : NamedTupleInstanceType, type2 : NamedTupleInstanceType)
common_descendent(type1 : ProcInstanceType, type2 : ProcInstanceType)
common_descendent(type1 : NonGenericModuleType | GenericModuleInstanceType, type2 : AliasType)
common_descendent(type1 : NonGenericModuleType | GenericModuleInstanceType, type2 : UnionType)
common_descendent(type1 : NonGenericModuleType | GenericModuleInstanceType, type2 : VirtualType)
common_descendent(type1 : NonGenericModuleType | GenericModuleInstanceType, type2 : GenericClassType)
common_descendent(type1 : GenericModuleInstanceType, type2 : GenericModuleInstanceType)
common_descendent(type1 : GenericModuleInstanceType, type2 : GenericModuleType)
common_descendent(type1 : NonGenericModuleType | GenericModuleInstanceType, type2 : Type)
common_descendent(type1 : GenericClassInstanceType, type2 : GenericClassType)
common_descendent(type1 : GenericClassType, type2 : GenericClassInstanceType)
common_descendent(type1 : GenericInstanceType, type2 : GenericInstanceType)
common_descendent(type1 : MetaclassType, type2 : VirtualMetaclassType)
common_descendent(type1 : VirtualMetaclassType, type2 : MetaclassType)
common_descendent(type1 : VirtualMetaclassType, type2 : VirtualMetaclassType)
common_descendent(type1 : GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType, type2 : MetaclassType | VirtualMetaclassType)
common_descendent(type1 : MetaclassType | VirtualMetaclassType, type2 : GenericClassInstanceMetaclassType | GenericModuleInstanceMetaclassType)
common_descendent(type1 : UnionType, type2 : Type)
common_descendent(type1 : AliasType, type2 : AliasType)
common_descendent(type1 : AliasType, type2 : Type)
common_descendent(type1 : TypeDefType, type2 : UnionType)
common_descendent(type1 : TypeDefType, type2 : AliasType)
common_descendent(type1 : TypeDefType, type2 : Type)
common_descendent(type1 : VirtualType, type2 : VirtualType)
common_descendent(type1 : VirtualType, type2 : AliasType)
common_descendent(type1 : VirtualType, type2 : UnionType)
common_descendent(type1 : VirtualType, type2 : Type)
common_descendent(type1 : NilType, type2 : VoidType)
common_descendent(type1 : GenericClassType, type2 : GenericClassType)
common_descendent(type1 : Type, type2 : AliasType)
common_descendent(type1 : Type, type2 : UnionType)
common_descendent(type1 : Type, type2 : VirtualType)
common_descendent(type1 : Type, type2 : GenericClassType)
common_descendent(type1 : Type, type2 : Type) common_descendent, least_common_ancestor(type1 : MetaclassType | GenericClassInstanceMetaclassType, type2 : MetaclassType | GenericClassInstanceMetaclassType)
least_common_ancestor(type1 : NonGenericModuleType | GenericModuleInstanceType | GenericClassType, type2 : NonGenericModuleType | GenericModuleInstanceType | GenericClassType)
least_common_ancestor(type1 : GenericClassType, type2 : ClassType | GenericClassInstanceType)
least_common_ancestor(type1 : NonGenericModuleType | GenericModuleInstanceType | GenericClassType, type2 : Type)
least_common_ancestor(type1 : ClassType | GenericClassInstanceType, type2 : GenericClassType)
least_common_ancestor(type1 : Type, type2 : NonGenericModuleType | GenericModuleInstanceType | GenericClassType)
least_common_ancestor(type1 : TupleInstanceType, type2 : TupleInstanceType)
least_common_ancestor(type1 : NamedTupleInstanceType, type2 : NamedTupleInstanceType)
least_common_ancestor(type1 : ClassType | GenericClassInstanceType, type2 : ClassType | GenericClassInstanceType)
least_common_ancestor(type1 : Type, type2 : Type) least_common_ancestor, merge(nodes : Enumerable(ASTNode)) : Type | Nil
merge(types : Array(Type)) : Type | Nil merge
Instance methods inherited from module Crystal::Annotatable
add_annotation(annotation_type : AnnotationType, value : Annotation)
add_annotation,
all_annotations : Array(Annotation) | Nil
all_annotations,
annotation(annotation_type : AnnotationType) : Annotation | Nil
annotation,
annotations(annotation_type : AnnotationType) : Array(Annotation) | Nilannotations : Hash(AnnotationType, Array(Annotation)) | Nil annotations, annotations=(annotations : Hash(AnnotationType, Array(Annotation)) | Nil) annotations=
Instance methods inherited from class Reference
==(other : self)==(other : JSON::Any)
==(other : YAML::Any)
==(other) ==, dup dup, hash(hasher) hash, initialize initialize, inspect(io : IO) : Nil inspect, object_id : UInt64 object_id, pretty_print(pp) : Nil pretty_print, same?(other : Reference) : Bool
same?(other : Nil) same?, to_s(io : IO) : Nil to_s
Constructor methods inherited from class Reference
new
new,
unsafe_construct(address : Pointer, *args, **opts) : self
unsafe_construct
Class methods inherited from class Reference
pre_initialize(address : Pointer)
pre_initialize
Instance methods inherited from class Object
! : Bool
!,
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other : JSON::Any)===(other : YAML::Any)
===(other) ===, =~(other) =~, as(type : Class) as, as?(type : Class) as?, class class, dup dup, hash(hasher)
hash hash, in?(collection : Object) : Bool
in?(*values : Object) : Bool in?, inspect(io : IO) : Nil
inspect : String inspect, is_a?(type : Class) : Bool is_a?, itself itself, nil? : Bool nil?, not_nil!(message)
not_nil! not_nil!, pretty_inspect(width = 79, newline = "\n", indent = 0) : String pretty_inspect, pretty_print(pp : PrettyPrint) : Nil pretty_print, responds_to?(name : Symbol) : Bool responds_to?, tap(&) tap, to_json(io : IO) : Nil
to_json : String to_json, to_pretty_json(indent : String = " ") : String
to_pretty_json(io : IO, indent : String = " ") : Nil to_pretty_json, to_s(io : IO) : Nil
to_s : String to_s, to_yaml(io : IO) : Nil
to_yaml : String to_yaml, try(&) try, unsafe_as(type : T.class) forall T unsafe_as
Class methods inherited from class Object
from_json(string_or_io : String | IO, root : String)from_json(string_or_io : String | IO) from_json, from_yaml(string_or_io : String | IO) from_yaml
Macros inherited from class Object
class_getter(*names, &block)
class_getter,
class_getter!(*names)
class_getter!,
class_getter?(*names, &block)
class_getter?,
class_property(*names, &block)
class_property,
class_property!(*names)
class_property!,
class_property?(*names, &block)
class_property?,
class_setter(*names)
class_setter,
def_clone
def_clone,
def_equals(*fields)
def_equals,
def_equals_and_hash(*fields)
def_equals_and_hash,
def_hash(*fields)
def_hash,
delegate(*methods, to object)
delegate,
forward_missing_to(delegate)
forward_missing_to,
getter(*names, &block)
getter,
getter!(*names)
getter!,
getter?(*names, &block)
getter?,
property(*names, &block)
property,
property!(*names)
property!,
property?(*names, &block)
property?,
setter(*names)
setter
Constructor Detail
Instance Method Detail
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.
Returns this type's metaclass, which holds class methods for this type.
Replace type parameters in this type with the type parameters of the given instance type.