Class: Yoda::Typing::Tree::If
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #infer_branch_nodes(condition_node, branch_nodes) ⇒ Types::Base
- #infer_type ⇒ Types::Type
- #node ⇒ AST::IfNode
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
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_type ⇒ Types::Type
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 |