It took a lot of work, but I was able to fix `Method#super_method` to return the same method that `super` would call when refinements are used: https://github.com/ruby/ruby/pull/16997 I'm not positive it handles every case correctly, ...jeremyevans0 (Jeremy Evans)
shugo (Shugo Maeda) wrote in #note-4: > It seems reasonable except that `RCLASS_INCLUDER(me->defined_class)` is better than `((struct RClass_and_rb_classext_t*)me->defined_class)->classext.as.iclass.includer`. Thank you. I updated th...jeremyevans0 (Jeremy Evans)
@shugo Thank you, I think I finally understand. After the first refinement method is called, the caller's scope no longer matters, because each `super` call site considers the refinements in effect at that `super` call site. You cannot u...jeremyevans0 (Jeremy Evans)
shugo (Shugo Maeda) wrote in #note-1: > Refinements for modules were initially prohibited, and were allowed in [Feature #12534] while `super` was still prohibited. Supporting `super` in a refinement for a module would go beyond a bug fi...jeremyevans0 (Jeremy Evans)
@mame thank you for clarifying. I apologize for implicating you :) I created backport PRs: * 4.0: https://github.com/ruby/ruby/pull/16976 * 3.4: https://github.com/ruby/ruby/pull/16977jeremyevans0 (Jeremy Evans)
Thank you for the report. I can confirm the issue. Note that it only affects Ruby 4.0. Ruby 3.4 is not affected, and Ruby 3.3 doesn't support arguments to `Thread.each_caller_location`. I traced the cause of the bug to commit:10767283dd0...jeremyevans0 (Jeremy Evans)
We currently support refinements of modules, even though doc/syntax/refinements.rdoc and https://github.com/ruby/ruby/wiki/Refinements-Spec imply that we would not respect refinements of included or prepended modules and would only respe...jeremyevans0 (Jeremy Evans)
shugo (Shugo Maeda) wrote in #note-7: > jeremyevans0 (Jeremy Evans) wrote: > ... As you mention below, this would be the CREF of the scope in which `Kernel#method` was invoked. > To make `Method#super_method` consistent with the act...jeremyevans0 (Jeremy Evans)
* [Bug #22058] {Method,InstanceMethod}#super_method doesn't work correctly for refined method with refinements for method active in the caller's scope (jeremyevans0) * I found semantic issues with #super_method for refined methods. *...jeremyevans0 (Jeremy Evans)
I've found that Method#super_method and InstanceMethod#super_method do not work correctly in some cases for refined methods. At the least, there is a definite bug, which is that #super_method inside a scope with a refinement activated f...jeremyevans0 (Jeremy Evans)