Class: Yoda::Typing::Tree::Send
- Inherits:
-
Base
- Object
- Base
- Yoda::Typing::Tree::Send
show all
- Defined in:
- lib/yoda/typing/tree/send.rb
Instance Attribute Summary
Attributes inherited from Base
#context, #node
Instance Method Summary
collapse
Methods inherited from Base
#build_child, #children, #generator, #initialize, #type
Instance Method Details
#arguments ⇒ Symbol
15
16
17
|
# File 'lib/yoda/typing/tree/send.rb', line 15
def arguments
@arguments ||= node.children.slice(2..-1).map(&method(:build_child))
end
|
#block_context ⇒ Object
47
48
49
|
# File 'lib/yoda/typing/tree/send.rb', line 47
def block_context
@block_context ||= method_resolver.generate_block_context(context: context, block_param_node: block_param_node)
end
|
#infer_send_node(block_param_node = nil, block_node = nil) ⇒ Types::Base
22
23
24
25
26
27
28
29
30
|
# File 'lib/yoda/typing/tree/send.rb', line 22
def infer_send_node(block_param_node = nil, block_node = nil)
if block_node
new_context = method_resolver.generate_block_context(context: context, block_param_node: block_param_node)
derive(context: new_context).infer(block_node)
end
tracer.bind_send(node: node, method_candidates: method_resolver.method_candidates, receiver_candidates: method_resolver.receiver_candidates)
method_resolver.return_type
end
|
#method_name ⇒ Symbol
10
11
12
|
# File 'lib/yoda/typing/tree/send.rb', line 10
def method_name
@method_name ||= node.children[1]
end
|
#method_resolver ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/yoda/typing/tree/send.rb', line 32
def method_resolver
@method_resolver ||= MethodResolver.new(
registry: context.registry,
receiver_type: receiver_type,
name: method_name.to_s,
argument_types: argument_types,
generator: generator,
implicit_receiver: receiver.nil?,
)
end
|
#receiver ⇒ Object
5
6
7
|
# File 'lib/yoda/typing/tree/send.rb', line 5
def receiver
@receiver ||= node.children[0] && build_child(node.children[0])
end
|
#receiver_type ⇒ Object
43
44
45
|
# File 'lib/yoda/typing/tree/send.rb', line 43
def receiver_type
@receiver_type ||= receiver ? receiver.type : context.receiver
end
|