class T::Types::TypedSet

def name

overrides Base
def name
  "T::Set[#{type.name}]"
end

def new(*args)

def new(*args)
  # Fine for this to blow up, because hopefully if they're trying to make a
  # Set, they don't mind putting (or already have put) a `require 'set'` in
  # their program directly.
  Set.new(*T.unsafe(args))
end

def recursively_valid?(obj)

overrides Base
def recursively_valid?(obj)
  # Re-implements non_forcing_is_a?
  return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set
  return false unless Object.const_defined?(:Set) # Set is not loaded yet
  obj.is_a?(Set) && super
end

def underlying_class

def underlying_class
  Set
end

def valid?(obj)

overrides Base
def valid?(obj)
  # Re-implements non_forcing_is_a?
  return false if Object.autoload?(:Set) # Set is meant to be autoloaded but not yet loaded, this value can't be a Set
  return false unless Object.const_defined?(:Set) # Set is not loaded yet
  obj.is_a?(Set)
end