class Steep::Interface::Block
def +(other)
def +(other) optional = self.optional? || other.optional? type = AST::Types::Proc.new(params: self.type.params | other.type.params, return_type: AST::Types::Union.build(types: [self.type.return_type, other.type.return_type])) self.class.new( type: type, optional: optional ) end
def ==(other)
def ==(other) other.is_a?(self.class) && other.type == type && other.optional == optional end
def closed?
def closed? type.closed? end
def free_variables
def free_variables type.free_variables end
def initialize(type:, optional:)
def initialize(type:, optional:) @type = type @optional = optional end
def map_type(&block)
def map_type(&block) self.class.new( type: type.map_type(&block), optional: optional ) end
def optional?
def optional? @optional end
def subst(s)
def subst(s) self.class.new( type: type.subst(s), optional: optional ) end
def to_optional
def to_optional self.class.new( type: type, optional: true ) end
def to_s
def to_s "#{optional? ? "?" : ""}{ #{type.params} -> #{type.return_type} }" end