class TypedRb::Model::TmBooleanOperator

abstraction

Attributes

lhs[RW]
operator[RW]
rhs[RW]

Public Class Methods

new(operator, lhs, rhs, node) click to toggle source
Calls superclass method TypedRb::Model::Expr::new
# File lib/typed/model/tm_boolean_operator.rb, line 9
def initialize(operator, lhs, rhs, node)
  super(node)
  @lhs = lhs
  @rhs = rhs
  @operator = operator
end

Public Instance Methods

check_type(context) click to toggle source
# File lib/typed/model/tm_boolean_operator.rb, line 16
def check_type(context)
  lhs_type = @lhs.check_type(context)
  rhs_type = @rhs.check_type(context)
  if lhs_type.is_a?(Types::Polymorphism::TypeVariable) || rhs_type.is_a?(Types::Polymorphism::TypeVariable)
    var = Types::TypingContext.local_type_variable
    var.compatible?(lhs_type, :gt)
    var.compatible?(rhs_type, :gt)
    var
  else
    types = [lhs_type, rhs_type].reject { |type| type.is_a?(Types::TyUnit) || type.is_a?(Types::TyError) }
    type = types.reduce(&:max)
    type  = Types::TyUnit.new if type.nil?
    type.node = node
    type
  end
end