Skip to content

struct Crystal::DefInstanceKey
inherits Struct

The key by which instantiated methods are cached.

For example, given:

def foo(x, y) # def object id: 1234
  x + y
end

foo(1, 2.5)

When foo(1) is analyzed the argument types are [Int32, Float64], and so we instantiate the method with those types (in this case there's no block type nor named argument types). We remember this instantiation with a key that includes the def's object id, argument types, etc., so when a call with the same target Def, argument types, etc., is found we don't need to re-analyze it.

Class methods

.new(def_object_id : UInt64, arg_types : Array(Type), block_type : Type?, named_args : Array(NamedArgumentType)?)

View source

Methods

#arg_types : Array(Type)

#block_type : Type?

#clone

View source

#copy_with(def_object_id _def_object_id = @def_object_id, arg_types _arg_types = @arg_types, block_type _block_type = @block_type, named_args _named_args = @named_args)

View source

#def_object_id : UInt64

#named_args : Array(NamedArgumentType)?