Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Prepend breaks module "implementer" search #2864
This code should work and it doesn't. This is the cause of the Rails master "each_with_index" bug when running tests:
module A def foo p 'ok' end end class X include A end class Y < X end module B end class Y prepend B end module A prepend B end Y.new.foo
I believe the problem is that our "findImplementer" logic for module methods ends up jumping above Enumerable in the search, due to the same module appearing in the hierarchy twice (due to lazy prepends).
Ok, I think I'm wrong. In monitoring a method search for the code above, we do walk the hierarchy correctly, but when it gets to the
My original fix for this was to make IncludedModuleWrapper keep searching prepended items until it finds a non-prepended, but that didn't seem to fix it.
The problem here was that I broke my prepend-searching fix.
In 7ac2331, I fixed prepends-in-a-module by searching the module's ancestors. However I searched too deeply, going into includes above the module that normally are not searched (they are copied into target hierarchy at include time).
Then in c725c69 I fixed the search to not go so deep...but I broke it by making it start at
The new fix, in b9473af, restores the proper starting point and terminates the search by looking for methodLocation (which indicates the module under which prepends should go). The final search covers the module itself, and all is well.