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, #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

#infer_branch_nodes(nodes) ⇒ Types::Base

Parameters:

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

Returns:



11
12
13
# File 'lib/yoda/typing/tree/if.rb', line 11

def infer_branch_nodes(nodes)
  Types::Union.new(nodes.map { |node| infer(node) })
end

#typeObject



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

def type
  infer_branch_nodes(node.children.slice(1..2).compact)
end