class Crystal::Call

Overview

A method call.

[ obj '.' ] name '(' ')' [ block ]

| [ obj '.' ] name '(' arg [ ',' arg ]* ')' [ block ] | [ obj '.' ] name arg [ ',' arg ]* [ block ] | arg name arg

The last syntax is for infix operators, and name will be the symbol of that operator instead of a string.

Defined in:

compiler/crystal/macros/methods.cr
compiler/crystal/semantic/ast.cr
compiler/crystal/semantic/call.cr
compiler/crystal/semantic/call_error.cr
compiler/crystal/semantic/lib.cr
compiler/crystal/syntax/ast.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from class Crystal::ASTNode

accept(visitor) accept, accept_children(visitor) accept_children, add_observer(observer) add_observer, at(node : ASTNode)
at(location : Location | Nil)
at
, at_end(node : ASTNode)
at_end(end_location : Location | Nil)
at_end
, bind(from = nil, &) bind, bind_to(node : ASTNode) : Nil
bind_to(nodes : Indexable) : Nil
bind_to
, class_desc class_desc, class_name class_name, clone clone, dependencies : SmallNodeList dependencies, doc doc, doc=(doc) doc=, enclosing_call : Call | Nil enclosing_call, enclosing_call=(enclosing_call : Call | Nil) enclosing_call=, end_location : Location | Nil end_location, end_location=(end_location : Location | Nil) end_location=, false_literal? false_literal?, filtered_by(filter) filtered_by, find_owner_trace(program, owner) find_owner_trace, freeze_type freeze_type, inspect(io : IO) : Nil inspect, interpret(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode) | Nil, block : Crystal::Block | Nil, interpreter : Crystal::MacroInterpreter, name_loc : Location | Nil) interpret, interpret_compare(other) interpret_compare, length : Int32 | Nil length, location : Location | Nil location, location=(location : Location | Nil) location=, macro_is_a?(macro_type : MacroType) : Bool macro_is_a?, map_type(type) map_type, name_location name_location, name_size name_size, no_returns? no_returns?, nop? nop?, notify_observers notify_observers, pretty_print(pp) pretty_print, propagate propagate, raise(message, inner = nil, exception_type = Crystal::TypeException) raise, raise_frozen_type(freeze_type, invalid_type, from) raise_frozen_type, remove_enclosing_call(enclosing_call) remove_enclosing_call, remove_observer(observer) remove_observer, restrict_type_to_freeze_type(freeze_type, type) restrict_type_to_freeze_type, restriction_of?(other : Underscore, owner, self_free_vars = nil, other_free_vars = nil)
restriction_of?(other : ASTNode, 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, owner, self_free_vars = nil, other_free_vars = nil)
restriction_of?
, set_enclosing_call(enclosing_call) set_enclosing_call, set_type(type : Type)
set_type(type : Nil)
set_type
, set_type_from(type, from) set_type_from, simple_literal? simple_literal?, single_expression single_expression, single_expression? single_expression?, stringify stringify, supports_autocast?(number_autocast : Bool = true) supports_autocast?, symbolize symbolize, to_macro_id to_macro_id, to_s(io : IO, macro_expansion_pragmas = nil, emit_doc = false, emit_location_pragmas : Bool = false) : Nil to_s, to_string(context) to_string, transform(transformer) transform, true_literal? true_literal?, truthy? truthy?, type
type(*, with_autocast = false)
type
, type=(type) type=, type? type?, type_from_dependencies : Type | Nil type_from_dependencies, unbind_from(nodes : Nil)
unbind_from(node : ASTNode)
unbind_from(nodes : Enumerable(ASTNode))
unbind_from
, update(from = nil) update, visibility visibility, visibility=(visibility : Visibility) visibility=, warning(message, inner = nil, exception_type = Crystal::TypeException) warning, wrong_number_of(elements, subject, given, expected)
wrong_number_of(elements, given, expected)
wrong_number_of
, wrong_number_of_arguments(subject, given, expected) wrong_number_of_arguments, wrong_number_of_message(elements, subject, given, expected)
wrong_number_of_message(elements, given, expected)
wrong_number_of_message

Class methods inherited from class Crystal::ASTNode

class_desc : String class_desc

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

def self.new(obj : ASTNode | Nil, name : String, args : Array(ASTNode) = [] of ASTNode, block : Nil | Crystal::Block = nil, block_arg : Crystal::ASTNode | Nil = nil, named_args : Nil | Array(Crystal::NamedArgument) = nil, global : Bool = false) #

[View source]
def self.new(name : String, args : Array(ASTNode) = [] of ASTNode, block : Block | Nil = nil, block_arg : ASTNode | Nil = nil, named_args : Array(NamedArgument) | Nil = nil, global : Bool = false) #

[View source]
def self.new(obj : ASTNode | Nil, name : String, *args : ASTNode, block : Block | Nil = nil, block_arg : ASTNode | Nil = nil, named_args : Array(NamedArgument) | Nil = nil, global : Bool = false) #

[View source]
def self.new(name : String, *args : ASTNode, block : Block | Nil = nil, block_arg : ASTNode | Nil = nil, named_args : Array(NamedArgument) | Nil = nil, global : Bool = false) #

[View source]

Class Method Detail

def self.append_def_full_name(owner, a_def, arg_types, str) #

[View source]
def self.def_full_name(owner, a_def, arg_types = nil) #

[View source]
def self.full_name(owner, method_name = name) #

[View source]
def self.global(name, *args : ASTNode) #

[View source]

Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def accept_children(visitor) #

[View source]
def append_def_full_name(owner, a_def, arg_types, str) #

[View source]
def append_matches(defs, arg_types, str, *, matched_def = nil, argument_name = nil) #

[View source]
def args : Array(ASTNode) #

[View source]
def args=(args : Array(ASTNode)) #

[View source]
def args_in_brackets=(args_in_brackets : Bool) #

[View source]
def args_in_brackets? : Bool #

[View source]
def attach_subclass_observer(type : Type) #

[View source]
def before_vars : MetaVars | Nil #

[View source]
def before_vars=(before_vars : MetaVars | Nil) #

[View source]
def block : Block | Nil #

[View source]
def block=(block : Block | Nil) #

[View source]
def block_arg : ASTNode | Nil #

[View source]
def block_arg=(block_arg : ASTNode | Nil) #

[View source]
def bubbling_exception(&) #

[View source]
def check_abstract_def_error(owner, matches, defs, def_name) #

[View source]
def check_fun_arg_type_matches(obj_type, self_arg, typed_def_arg, index) #

[View source]
def check_fun_args_size_match(obj_type, external) #

[View source]
def check_fun_args_types_match(obj_type, typed_def) #

[View source]
def check_fun_out_args(untyped_def) #

[View source]
def check_lib_call_named_args(external) #

[View source]
def check_macro_wrong_number_of_arguments(owner, def_name) #

[View source]
def check_not_lib_out_args #

[View source]
def check_recursive_splat_call(a_def, args, &) #

[View source]
def check_return_type(typed_def, typed_def_return_type, match, match_owner) #

[View source]
def check_tuple_indexer(owner, def_name, args, arg_types) #

[View source]
def check_visibility(match) #

[View source]
def clone_without_location #

[View source]
def convert_numeric_argument(self_arg, unaliased_type, expected_type, actual_type, index) #

[View source]
def convert_to_logical_operator(def_name) #

[View source]
def def_full_name(owner, a_def, arg_types = nil) #

[View source]
def doc : String | Nil #
Description copied from class Crystal::ASTNode

Returns the doc comment attached to this node. Not every node supports having doc comments, so by default this returns nil.


[View source]
def doc=(doc : String | Nil) #

[View source]
def enclosing_def(context) #

[View source]
def expanded : ASTNode | Nil #

[View source]
def expanded=(expanded : ASTNode | Nil) #

[View source]
def expanded_macro : Macro | Nil #

[View source]
def expanded_macro=(expanded_macro : Macro | Nil) #

[View source]
def expansion=(expansion : Bool) #

[View source]
def expansion? : Bool #

[View source]
def extract_missing_named_args(a_def, named_args) #

[View source]
def full_name(owner, def_name = name) #

[View source]
def global=(global : Bool) #

[View source]
def global? : Bool #

[View source]
def has_any_args? #

Returns true if this call has any arguments.

Does not consider a block, only block argument. foo {} would be false, but foo(&x) would be true.


[View source]
def has_parentheses=(has_parentheses : Bool) #

[View source]
def has_parentheses? : Bool #

[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def in_macro_target(&) #

[View source]
def instantiate(signature, matches, owner, self_type, with_autocast) #

[View source]
def interpret(method : String, args : Array(ASTNode), named_args : Hash(String, ASTNode) | Nil, block : Crystal::Block | Nil, interpreter : Crystal::MacroInterpreter, name_loc : Location | Nil) #

[View source]
def lookup_macro #

[View source]
def lookup_matches #

[View source]
def lookup_matches(*, with_autocast = false) #

[View source]
def lookup_matches_checking_expansion(owner, signature, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : AliasType, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : UnionType, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : Program, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : FileModule, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : NonGenericModuleType | GenericModuleInstanceType | GenericType, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : LibType, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in(owner : Type, arg_types, named_args_types, self_type = nil, def_name = self.name, search_in_parents = true, with_autocast = false) #

[View source]
def lookup_matches_in_type(owner, arg_types, named_args_types, self_type, def_name, search_in_parents, search_in_toplevel = true, with_autocast = false) #

[View source]
def lookup_matches_with_scope_in(owner, arg_types, named_args_types, with_autocast = false) #

[View source]
def lookup_matches_with_signature(owner : Program, signature, search_in_parents, with_autocast) #

[View source]
def lookup_matches_with_signature(owner, signature, search_in_parents, with_autocast) #

[View source]
def lookup_matches_with_splat(with_autocast) #

[View source]
def lookup_matches_without_splat(arg_types, named_args_types, with_autocast) #

[View source]
def lookup_previous_def_matches(arg_types, named_args_types, with_autocast) #

[View source]
def lookup_super_matches(arg_types, named_args_types, with_autocast) #

[View source]
def match_block_arg(match) #

Match the given block with the given block argument specification (&block : A, B, C -> D)


[View source]
def missing_argument_message(a_def, named_args) #

[View source]
def name : String #

[View source]
def name=(name : String) #

[View source]
def name_end_location #

[View source]
def name_location : Location | Nil #

[View source]
def name_location=(name_location : Location | Nil) #

[View source]
def name_size #

[View source]
def name_size=(name_size : Int32) #

[View source]
def named_args : Array(NamedArgument) | Nil #

[View source]
def named_args=(named_args : Array(NamedArgument) | Nil) #

[View source]
def named_tuple_indexer_helper(args, arg_types, owner, instance_type, nilable, &) #

[View source]
def obj : ASTNode | Nil #

[View source]
def obj=(obj : ASTNode | Nil) #

[View source]
def obj_and_args_types_set? #

[View source]
def on_new_subclass #

[View source]
def parent_visitor : MainVisitor #

[View source]
def parent_visitor=(parent_visitor : MainVisitor) #

[View source]
def parent_visitor? : MainVisitor | Nil #

[View source]
def prepare_typed_def_with_args(untyped_def, owner, self_type, arg_types, block_arg_type, named_args_types) #

[View source]
def pretty_print(pp) : Nil #

[View source]
def previous_def? #

[View source]
def program #

[View source]
def raise_abstract_method_must_be_implemented(a_def, owner) #

[View source]
def raise_if_block_too_nested(block_nest) #

[View source]
def raise_matches_not_found(owner, def_name, arg_types, named_args_types, matches = nil, with_autocast = false, number_autocast = true) #

[View source]
def raise_matches_not_found_for_virtual_metaclass_new(owner) #

[View source]
def recalculate #

[View source]
def recalculate_lib_call(obj_type) #

[View source]
def replace_block_arg_with_block(block_arg) #

[View source]
def replace_splats #

[View source]
def scope : Type #

[View source]
def scope=(scope : Type) #

[View source]
def scope? : Type | Nil #

[View source]
def signature(io : IO) : Nil #

[View source]
def single_def_error_message(defs, named_args) #

[View source]
def super? #

[View source]
def target_def #

[View source]
def target_defs : Array(Def) | Nil #

[View source]
def target_defs=(target_defs : Array(Def) | Nil) #

[View source]
def to_macro_id #

[View source]
def tuple_indexer_helper(args, arg_types, owner, instance_type, nilable, &) #

[View source]
def uses_with_scope=(uses_with_scope : Bool) #

[View source]
def uses_with_scope? : Bool #

[View source]
def visibility : Crystal::Visibility #

[View source]
def visibility=(visibility : Crystal::Visibility) #

[View source]
def with_scope : Type | Nil #

[View source]
def with_scope=(with_scope : Type | Nil) #

[View source]