class Steep::Interface::Interface::Combination
def self.intersection(types)
def self.intersection(types) case types.size when 0 raise "Combination.intersection called with zero types" when 1 types.first else new(operator: :intersection, types: types) end end
def self.overload(types, incompatible:)
def self.overload(types, incompatible:) new(operator: :overload, types: types).incompatible!(incompatible) end
def self.union(types)
def self.union(types) case types.size when 0 raise "Combination.union called with zero types" when 1 types.first else new(operator: :union, types: types) end end
def incompatible!(value)
def incompatible!(value) @incompatible = value self end
def incompatible?
def incompatible? @incompatible end
def initialize(operator:, types:)
def initialize(operator:, types:) @types = types @operator = operator @incompatible = false end
def intersection?
def intersection? operator == :intersection end
def overload?
def overload? operator == :overload end
def to_s
def to_s case operator when :overload "{ #{types.map(&:to_s).join(" | ")} }" when :union "[#{types.map(&:to_s).join(" | ")}]" when :intersection "[#{types.map(&:to_s).join(" & ")}]" end end
def union?
def union? operator == :union end