class Sorbet::Private::ConstantLookupCache

def all_module_aliases

def all_module_aliases
  ret = {}
  @all_constants.map do |_key, struct|
    next if struct.nil? || !Sorbet::Private::RealStdlib.real_is_a?(struct.const, Module) || struct.aliases.size < 2
    if struct.owner != nil
      ret[struct.primary_name] = struct.aliases.reject do |name|
        # ignore the primary
        next true if name == struct.primary_name
        prefix, _, _ = name.rpartition('::')
        # an alias that exists at the top-level
        next false if prefix == ""
        # if the prefix is the same syntactically, then this is a good alias
        next false if prefix == struct.owner.primary_name
        # skip the alias if the owner is the same
        other_owner_const = Sorbet::Private::RealStdlib.real_const_get(Object, prefix, false)
        struct.owner.const == other_owner_const
      end
    else
      # top-level names
      ret[struct.primary_name] = struct.aliases.reject {|name| name == struct.primary_name }
    end
  end
  ret
end