Actions
Bug #22462
openMethod#== can return false for methods that should be considered equal
Bug #22462:
Method#== can return false for methods that should be considered equal
Description
When a Method is created using UnboundMethod#bind and #super_method, the order in which the #bind and #super_method were applied could result in Method objects that were considered unequal.
I believe we should have the invariant: for any UnboundMethod um where super_method is not nil and o is a valid object to bind to um, the following code should be true:
However, that didn't work correctly in some cases:
module M; def m = [:M, *super]; end
module N; include M; end
class C; def m = :C; end
class SC < C
include N
prepend M
def m = [:SC, *super]
end
o = SC.new
um = SC.instance_method(:m).super_method.super_method # M#m below SC (included via N)
um.bind(o).super_method == um.super_method.bind(o)
# => false # should be true
There is a similar invariant for Method: for any Method m where super_method is not nil, the following code should be true:
This appears to already hold, as the existing refinement tests already checked for this behavior.
I've submitted a PR to fix this issue: https://github.com/ruby/ruby/pull/19474
Actions