Feature #15777

Updated by fxn (Xavier Noria) over 2 years ago

Zeitwerk needs to be able to check if a given class or module has an autoload defined for a certain constant name, that would be `autoload?(cname, false)`, similar to `const_defined?(cname, false)`. 

 `Module#autoload?` looks the ancestors up, so by now the gem emulates the behavior the best it can comparing strings in ancestors. This cannot be implemented as `autoload?(cname) && const_defined?(cname, false)` because Zeitwerk sets autoloads on directories (sorry), and `const_defined?` checks if the file exists. Since the file does not exist, it removes the autoload if there is actually one.