Skip to content

Commit

Permalink
Make autoload dynamically dispatch to require. Fixes #5403.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Nov 1, 2018
1 parent 3e1e766 commit 31d1414
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/runtime/load/LoadService.java
Expand Up @@ -406,7 +406,7 @@ public boolean require(String requireName) {
}

public boolean autoloadRequire(String requireName) {
return smartLoadInternal(requireName, false) != RequireState.CIRCULAR;
return runtime.getTopSelf().callMethod(runtime.getCurrentContext(), "require", runtime.newString(requireName)).isTrue();
}

private enum RequireState {
Expand Down
3 changes: 1 addition & 2 deletions spec/tags/ruby/core/kernel/autoload_tags.txt
@@ -1,9 +1,8 @@
fails:Kernel.autoload sets the autoload constant in Object's constant table
fails:Kernel#autoload registers a file to load the first time the named constant is accessed
fails:Kernel#autoload? returns the name of the file that will be autoloaded
fails:Kernel#autoload when called from included module's method setups the autoload on the included module
fails:Kernel#autoload when called from included module's method the autoload relative to the included module works
fails:Kernel.autoload when called from included module's method setups the autoload on the included module
fails:Kernel.autoload when called from included module's method the autoload is reacheable from the class too
fails:Kernel.autoload when called from included module's method the autoload relative to the included module works
fails:Kernel#autoload calls main.require(path) to load the file
fails:Kernel#autoload registers a file to load the first time the named constant is accessed
1 change: 0 additions & 1 deletion test/mri/excludes/TestAutoload.rb
@@ -1,3 +1,2 @@
exclude :test_autoload_while_autoloading, "needs investigation"
exclude :test_bug_13526, "racey test that doesn't behave as expected with concurrent threads #5294"
exclude :test_require_implemented_in_ruby_is_called, "attempted to dispatch to require but it seems to recursively call itself"

0 comments on commit 31d1414

Please sign in to comment.