Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Problem with Class.instance_methods after Module.prepend #4723
Hello - We are currently in the process of upgrading our Jruby application to Rails 5, and have discovered an issue with the
This gem uses
Example from Rails:
In Rails 4-2 stable using Jruby 188.8.131.52:
Array.instance_methods.include?(:each_with_index) => true
In Rails 5-1 stable using Jruby 184.108.40.206:
Array.instance_methods.include?(:each_with_index) => false
I think I reproduced the problem below outside of Rails. Let me know if you need anymore information.
Provide at least:
module A def a end end module B def b end end module C def c end end class D include A include B end D.instance_methods.include?(:b) => true B.prepend C D.instance_methods.include?(:b) => true
D.instance_methods.include?(:b) => true B.prepend C D.instance_methods.include?(:b) => false
referenced this issue
Aug 3, 2017
Definitely seems to be limited to prepends into modules.
No luck so far in my exploration. I returned to MRI source to see how they walk the hierarchy, and as far as I can tell they don't do anything special for prepends on modules. The problem as I see it is that once prepended, Enumerable's methods move up to the prepend wrapper, and only the prepended module's methods get walked because we don't expect a hierarchy within modules.
However we're able to call those methods just fine, so method searching is doing the right thing.