Class: Yoda::Typing::Tree::MethodDef

Inherits:
Base
  • Object
show all
Includes:
MethodInferable
Defined in:
lib/yoda/typing/tree/method_def.rb

Instance Attribute Summary

Attributes inherited from Base

#context, #tracer

Instance Method Summary collapse

Methods included from MethodInferable

#infer_method_type

Methods inherited from Base

#build_child, #generator, #infer_child, #initialize, #inspect, #pretty_print, #type

Constructor Details

This class inherits a constructor from Yoda::Typing::Tree::Base

Instance Method Details

#body_nodeTypes::Type

Returns:



28
29
30
# File 'lib/yoda/typing/tree/method_def.rb', line 28

def body_node
  node.body
end

#infer_typeTypes::Base

Returns:



13
14
15
# File 'lib/yoda/typing/tree/method_def.rb', line 13

def infer_type
  infer_method_type(receiver_type: self_type)
end

#nodeAST::DefNode

Returns:



# File 'lib/yoda/typing/tree/method_def.rb', line 9


#node_nameSymbol

Returns:

  • (Symbol)


18
19
20
# File 'lib/yoda/typing/tree/method_def.rb', line 18

def node_name
  node.name
end

#parameters_nodeAST::ParametersNode

Returns:



23
24
25
# File 'lib/yoda/typing/tree/method_def.rb', line 23

def parameters_node
  node.parameters
end

#self_typeTypes::Type

Returns:



33
34
35
36
37
# File 'lib/yoda/typing/tree/method_def.rb', line 33

def self_type
  @self_type ||= begin
    context.method_receiver
  end
end