module T::Types::Simple::Private::Pool

def self.type_for_module(mod)

def self.type_for_module(mod)
  cached = @cache[mod]
  return cached if cached
  type = if mod == ::Array
    T::Array[T.untyped]
  elsif mod == ::Hash
    T::Hash[T.untyped, T.untyped]
  elsif mod == ::Enumerable
    T::Enumerable[T.untyped]
  elsif mod == ::Enumerator
    T::Enumerator[T.untyped]
  elsif mod == ::Range
    T::Range[T.untyped]
  elsif !Object.autoload?(:Set) && Object.const_defined?(:Set) && mod == ::Set
    T::Set[T.untyped]
  else
    # ideally we would have a case mapping from ::Class -> T::Class here
    # but for backwards compatibility we don't have that, and instead
    # have a special case in subtype_of_single?
    Simple.new(mod)
  end
  # Unfortunately, we still need to check if the module is frozen,
  # since on 2.6 and older WeakMap adds a finalizer to the key that is added
  # to the map, so that it can clear the map entry when the key is
  # garbage collected.
  # For a frozen object, though, adding a finalizer is not a valid
  # operation, so this still raises if `mod` is frozen.
  if CACHE_FROZEN_OBJECTS || (!mod.frozen? && !type.frozen?)
    @cache[mod] = type
  end
  type
end