Class: Yoda::Typing::Tree::Method

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

Instance Attribute Summary

Attributes inherited from Base

#context, #node

Instance Method Summary collapse

Methods inherited from Base

#build_child, #children, #generator, #initialize

Constructor Details

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

Instance Method Details

#argumentObject



9
10
11
# File 'lib/yoda/typing/tree/method.rb', line 9

def argument
  @argument ||= build_child(node.children[1])
end

#bodyObject



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

def body
  @body ||= node.children[2] && build_child(node.children[2], context: method_context)
end

#method_contextObject



26
27
28
# File 'lib/yoda/typing/tree/method.rb', line 26

def method_context
  @method_context ||= method_definition_provider.generate_method_context(context: context, args_node: args_node)
end

#nameObject



5
6
7
# File 'lib/yoda/typing/tree/method.rb', line 5

def name
  node.children.first
end

#receiver_typeObject



22
23
24
# File 'lib/yoda/typing/tree/method.rb', line 22

def receiver_type
  @receiver_type ||= generator.union(context.current_objects.map { |object| generator.object_type(object) })
end

#typeTypes::Base

Returns:



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

def type
  @type ||= generator.symbol_type
end