class RBS::Types::Optional

def ==(other)

def ==(other)
  other.is_a?(Optional) && other.type == type
end

def each_type

def each_type
  if block_given?
    yield type
  else
    enum_for :each_type
  end
end

def free_variables(set = Set.new)

def free_variables(set = Set.new)
  type.free_variables(set)
end

def has_classish_type?

def has_classish_type?
  each_type.any? {|type| type.has_classish_type? }
end

def has_self_type?

def has_self_type?
  each_type.any? {|type| type.has_self_type? }
end

def hash

def hash
  self.class.hash ^ type.hash
end

def initialize(type:, location:)

def initialize(type:, location:)
  @type = type
  @location = location
end

def map_type(&block)

def map_type(&block)
  if block
    Optional.new(
      type: yield(type),
      location: location
    )
  else
    enum_for :map_type
  end
end

def map_type_name(&block)

def map_type_name(&block)
  Optional.new(
    type: type.map_type_name(&block),
    location: location
  )
end

def sub(s)

def sub(s)
  return self if s.empty?
  self.class.new(type: type.sub(s), location: location)
end

def to_json(state = _ = nil)

def to_json(state = _ = nil)
  { class: :optional, type: type, location: location }.to_json(state)
end

def to_s(level = 0)

def to_s(level = 0)
  case t = type
  when RBS::Types::Literal
    case t.literal
    when Symbol
      return "#{type.to_s(1)} ?"
    end
  when RBS::Types::Proc
    return "(#{type.to_s(1)})?"
  end
  "#{type.to_s(1)}?"
end

def with_nonreturn_void?

def with_nonreturn_void?
  each_type.any? {|type| type.with_nonreturn_void? }
end