Class: Yoda::Typing::Tree::If

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

Instance Attribute Summary

Attributes inherited from Base

#context, #tracer

Instance Method Summary collapse

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

#infer_branch_nodes(condition_node, branch_nodes) ⇒ Types::Base

Parameters:

  • branch_nodes (Array<::AST::Node>)

Returns:



15
16
17
18
# File 'lib/yoda/typing/tree/if.rb', line 15

def infer_branch_nodes(condition_node, branch_nodes)
  infer_child(condition_node)
  generator.union_type(*branch_nodes.map { |node| infer_child(node) })
end

#infer_typeTypes::Type

Returns:



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

def infer_type
  infer_branch_nodes(node.children.first, node.children.slice(1..2).compact)
end

#nodeAST::IfNode

Returns:



# File 'lib/yoda/typing/tree/if.rb', line 5