From: "nagachika (Tomoyuki Chikanaga)" Date: 2021-12-24T05:54:37+00:00 Subject: [ruby-core:106801] [Ruby master Bug#17725] Prepend breaks ability to override optimized methods Issue #17725 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED to 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED I gave up to find a workaround. I will backport fb4cf204a662a8cd9dafef6f31f2bd0db9129abe and fa0279d947c3962c3f8c32852278d3ebb964cb19 even though they introduce an incompatibility. I believe the incompatibility (the Array#size is going to have an independent method entry instead of being defined as the alias of Array#length) couldn't cause any problem in the real world applications... ---------------------------------------- Bug #17725: Prepend breaks ability to override optimized methods https://bugs.ruby-lang.org/issues/17725#change-95610 * Author: joshuadreed (Josh Reed) * Status: Closed * Priority: Normal * ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19] * Backport: 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED ---------------------------------------- Prepending any module to `String` and `Hash` (and possibly other or all classes?) blocks the ability to `alias` As an example: ``` ruby module Dummy; end # String.prepend(Dummy) class String alias_method(:old_plus, :+) def + other puts 'blah blah' old_plus(other) end end 'a' + 'b' > blah blah ``` ``` ruby module Dummy; end String.prepend(Dummy) class String alias_method(:old_plus, :+) def + other puts 'blah blah' old_plus(other) end end 'a' + 'b' > ``` Prepending after an `alias` does not affect the previous `alias` -- https://bugs.ruby-lang.org/ Unsubscribe: