class Module

def autoload(const, path)

def autoload(const, path)
  fallback = false
  # 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 => error
  error.instance_variable_set(Bootsnap::LoadPathCache::ERROR_TAG_IVAR, true)
  raise(error)
rescue Bootsnap::LoadPathCache::ReturnFalse
  false
rescue Bootsnap::LoadPathCache::FallbackScan
  fallback = true
ensure
  # We raise from `ensure` so that any further exception don't have FallbackScan as a cause
  # See: https://github.com/Shopify/bootsnap/issues/250
  autoload_without_bootsnap(const, path)
end