Skip to content

abstract class Crystal::ClassType
inherits Crystal::ModuleType

Abstract base type for classes and structs (types that can be allocated via the allocate method).

Included modules

Crystal::DefInstanceContainer Crystal::InstanceVarInitializerContainer Crystal::SubclassObservable

Direct known subclasses

Crystal::GenericClassType Crystal::MetaclassType Crystal::NonGenericClassType Crystal::PrimitiveType

Class methods

.new(program, namespace, name, superclass, add_subclass = true)

View source

Methods

#abstract=(abstract __arg0)

View source

#abstract? : Bool

Returns true if this type is abstract.

View source

#add_subclass(subclass)

View source

#can_be_stored=(can_be_stored)

View source

#can_be_stored? : Bool

Returns true if this type can be assigned to an instance or class variable, or used in a generic type argument.

As of now, abstract base type such as Object, Reference, Value, Int, and unbound generic types such as Array(T), can't be stored.

View source

#common_ancestor(other : VirtualType)

View source

#common_ancestor(other : ClassType | GenericClassInstanceType)

View source

#depth : Int32

View source

#extern=(extern)

View source

#extern? : Bool

Returns true if this is an extern C struct or union (extern_union? tells which one)

View source

#extern_union=(extern_union)

View source

#extern_union? : Bool

Returns true if this is an extern C union (extern? will be true too)

View source

#force_add_subclass

View source

#lookup_new_in_ancestors=(lookup_new_in_ancestors)

View source

#lookup_new_in_ancestors? : Bool

Should new be looked up in ancestors?

This is true if this type doesn't define any initialize methods.

View source

#metaclass=(metaclass : Type?)

View source

#packed=(packed)

View source

#packed? : Bool

Returns true if this type has the @[Packed] annotation on it (only applicable for C structs)

View source

#struct=(struct __arg0)

View source

#struct? : Bool

Returns true if this type is a struct.

View source

#subclasses : Array(Crystal::Type)

Returns direct subclasses of this type.

View source

#superclass : Type?

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

View source

#superclass=(superclass)

View source

#type_desc

View source