class Macros::TypeNode

Overview

Represents a type in the program, like Int32 or String.

Superclass hierarchy

Object
Reference
Macros::ASTNode
Macros::TypeNode

Defined in:

Instance Method Summary

Instance Method Detail

def abstract? : BoolLiteral

Returns true if this type is abstract.


def has_attribute?(name : StringLiteral | SymbolLiteral) : BoolLiteral

Returns true if this type has an attribute. For example @[Flags] or @[Packed] (the name you pass to this method is "Flags" or "Packed" in these cases).


def instance_vars : Macros::ArrayLiteral(MetaVar)

Returns the instance variables of this type.


def length : NumberLiteral

Returns the number of elements in this tuple type or tuple metaclass type. Gives a compile error if this is not one of those types.


def methods : Array(Def)

Returns the instance methods defined by this type, without including inherited methods.


def name : MacroId

Returns the fully qualified name of this type.


def subclasses : Macros::ArrayLiteral(MacroId)

Returns the constants and types defined by this type.


def superclass : TypeNode | NilLiteral

Returns the direct superclass of this type.


def type_params : Macros::ArrayLiteral(TypeNode)

Returns the type parameters of the generic type. If the type is not generic, an empty array is returned.


def union? : BoolLiteral

Returns true if this type is a union type, false otherwise.

See also: #union_types.


def union_types : Macros::ArrayLiteral(TypeNode)

Returns the types comforming a union type, if this is a union type. Gives a compile error otherwise.

See also: #union?.