class TypedRb::Model::TmArrayLiteral

Attributes

elements[R]

Public Class Methods

new(elements, node) click to toggle source
Calls superclass method TypedRb::Model::Expr::new
# File lib/typed/model/tm_array_literal.rb, line 7
def initialize(elements, node)
  super(node)
  @elements = elements
end

Public Instance Methods

check_type(context) click to toggle source
# File lib/typed/model/tm_array_literal.rb, line 12
def check_type(context)
  element_types = elements.map { |element|  element.check_type(context) }
  max_type = element_types.reduce(&:max)
  type_var = Types::Polymorphism::TypeVariable.new('Array:T',
                                                   :node => node,
                                                   :gen_name => false,
                                                   :upper_bound => max_type,
                                                   :lower_bound => max_type)
  type_var.bind(max_type)
  Types::TyGenericObject.new(Array, [type_var], node)
end