Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Consider an autoload resolved if #resolve didn't return nil in Autolo…
…ad#call

This fixes cases of autoload "errors" mentioned by @robin850 in
#2934 (comment)
and https://gist.github.com/robin850/3eeaed2538f50a9887c2

This is an explanation of the issue:
We already have A::B been autoloaded by the main thread. When c.rb (see
any of the previous links) is being autoloaded in another thread, class
A::B is being opened using Rubinius.open_class_under (through
Rubinius.open_class).
Since module A has an Autoload entry for B in its constant_table,
open_class_under tries to call #call on this Autload object, which returns nil
because #resolve returns false (CodeLoader.require returns false
if a feature is already been loaded).
With nil returned, open_class_under decided to create a new Class object
for B, which means the autoload entry it already had for :C is lost,
resulting in constant A::B::C not being found.
  • Loading branch information
ahmadsherif committed Feb 22, 2016
1 parent 046bf33 commit 01a7c2f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/autoload.rb
Expand Up @@ -40,7 +40,7 @@ def call(under, honor_require=false)
if !undefined.equal?(constant) && Thread.current == thread
constant
else
worked = resolve
worked = !resolve.nil?

if !honor_require or worked
find_const under
Expand Down

0 comments on commit 01a7c2f

Please sign in to comment.