Feature #18798
Updated by ko1 (Koichi Sasada) over 2 years ago
Now `UnboundMethod` for a same method from a superclass and an inherited class are not `==`. ```ruby class C def foo = :C $mc = instance_method(:foo) end class D < C $md = instance_method(:foo) end p $mc == $md #=> false p $mc.owner #=> C p $mc.owner == $mc.owner #=> true p $mc.source_location == $mc.source_location #=> true p $mc.inspect #=> "#<UnboundMethod: C#foo() t.rb:3>" p $md.inspect #=> "#<UnboundMethod: D(C)#foo() t.rb:3>" ``` How about to make it `UnboundMethod#==` return true for this case? Rule: "return true if the UnboundMethod objects point to a points same method definition" seems simple. FYI: On aliased unbound methods point to a same method are `==`. ```ruby class C def foo = :C alias bar foo $mfoo = instance_method(:foo) $mbar = instance_method(:bar) end p $mfoo, $mbar #=> #<UnboundMethod: C#foo() t.rb:2> #=> #<UnboundMethod: C#bar(foo)() t.rb:2> p $mfoo == $mbar #=> true ```