Project

General

Profile

Actions

Bug #17725

closed

Prepend breaks ability to override optimized methods

Added by joshuadreed (Josh Reed) over 3 years ago. Updated almost 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin19]
[ruby-core:102884]

Description

Prepending any module to String and Hash (and possibly other or all classes?) blocks the ability to alias

As an example:

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
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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0