Sha256: 99db85ad86fae356f415432c5dc57215c115ae9cbe60a8af1bfa75dc249b54b6

Contents?: true

Size: 579 Bytes

Versions: 2

Compression:

Stored size: 579 Bytes

Contents

module Yoda
  module Typing
    module Tree
      class If < Base
        # @!method node
        #   @return [AST::IfNode]

        # @return [Types::Type]
        def infer_type
          infer_branch_nodes(node.children.first, node.children.slice(1..2).compact)
        end

        # @param branch_nodes [Array<::AST::Node>]
        # @return [Types::Base]
        def infer_branch_nodes(condition_node, branch_nodes)
          infer_child(condition_node)
          generator.union_type(*branch_nodes.map { |node| infer_child(node) })
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yoda-language-server-0.10.1 lib/yoda/typing/tree/if.rb
yoda-language-server-0.10.0 lib/yoda/typing/tree/if.rb