Issue #15777 has been reported by fxn (Xavier Noria).

----------------------------------------
Feature #15777: autoload?(cname, inherit=true)
https://bugs.ruby-lang.org/issues/15777

* Author: fxn (Xavier Noria)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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.




-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>