class Module

def autoload(const, path)

def autoload(const, path)
  # NOTE: This may defeat LoadedFeaturesIndex, but it's not immediately
  # obvious how to make it work. This feels like a pretty niche case, unclear
  # if it will ever burn anyone.
  #
  # The challenge is that we don't control the point at which the entry gets
  # added to $LOADED_FEATURES and won't be able to hook that modification
  # since it's done in C-land.
  autoload_without_bootsnap(const, Bootsnap::LoadPathCache.load_path_cache.find(path) || path)
rescue LoadError => e
  e.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
  raise(e)
rescue Bootsnap::LoadPathCache::ReturnFalse
  false
rescue Bootsnap::LoadPathCache::FallbackScan
  fallback = true
ensure
  if fallback
    autoload_without_bootsnap(const, path)
  end
end