joshuadreed (Josh Reed)
- Login: joshuadreed
- Registered on: 03/04/2021
- Last sign in: 03/16/2021
Issues
| open | closed | Total | |
|---|---|---|---|
| Assigned issues | 0 | 0 | 0 |
| Reported issues | 0 | 1 | 1 |
Activity
03/16/2021
-
06:47 PM Ruby Bug #17725: Prepend breaks ability to override optimized methods
- One more detail.
``` ruby
module Dummy; end
class String
alias_method(:old_plus, :+)
def + other
puts 'blah blah'
old_plus(other)
end
end
String.prepend(Dummy)
class String
alias_method(:old_plus2, :+)
def + other
... -
06:15 PM Ruby Bug #17725: Prepend breaks ability to override optimized methods
- So, I set out to test my hypothesis regarding refinements. I've never used refinements prior to this, so it's still possible there's an interaction somewhere, but at least not in the way I was thinking.
``` ruby
module Dummy; end
... -
05:34 PM Ruby Bug #17725: Prepend breaks ability to override optimized methods
``` ruby
module Dummy; end
class Foo
def ten
10
end
end
Foo.prepend(Dummy)
class Foo
alias_method(:old_ten, :ten)
def ten
puts 'blah blah'
old_ten
end
end
Foo.new.ten
> blah blah
...-
05:26 PM Ruby Bug #17725 (Closed): Prepend breaks ability to override optimized methods
- 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 ...