class TypedRb::Model::TmIfElse

Attributes

condition_expr[R]
else_expr[RW]
then_expr[R]

Public Class Methods

new(node, condition_expr, then_expr, else_expr) click to toggle source
Calls superclass method TypedRb::Model::Expr::new
# File lib/typed/model/tm_if_else.rb, line 8
def initialize(node, condition_expr, then_expr, else_expr)
  super(node, nil)
  @condition_expr = condition_expr
  @then_expr = then_expr || Types::TyUnit.new
  @else_expr = else_expr || Types::TyUnit.new
end

Public Instance Methods

check_type(context) click to toggle source
# File lib/typed/model/tm_if_else.rb, line 15
def check_type(context)
  either_type = Types::TyEither.new(node)
  either_type.compatible_either?(then_expr.check_type(context))
  either_type.compatible_either?(else_expr.check_type(context))
  either_type.has_jump? ? either_type : either_type[:normal]
end