From 59e389af2893c0fcf8b2cfa008c9a16825bf56ff Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Sat, 3 Dec 2022 05:55:33 +0900 Subject: UnboundMethod only refer defined_class UnboundMethod records caller's class, like `D` or `E` on the following case: ```ruby class C def foo = :foo end class D < C end class E < C end d = D.instance_method(:foo) e = E.instance_method(:foo) ``` But `d` and `e` only refers `C#foo` so that UnboundMethod doesn't record `D` or `E`. This behavior changes the following methods: * `UnboundMethod#inspect` (doesn't show caller's class) * `UnboundMethod#==` (`d == e` for example) fix https://bugs.ruby-lang.org/issues/18798 --- test/ruby/test_method.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index d2c7b6e1dd..a04666890e 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -1236,12 +1236,12 @@ class TestMethod < Test::Unit::TestCase unbound = b.instance_method(:foo) assert_equal unbound, b.public_instance_method(:foo) - assert_equal "#", unbound.inspect + assert_equal "#", unbound.inspect assert_equal [[:opt, :arg]], unbound.parameters a.remove_method(:foo) - assert_equal "#", unbound.inspect + assert_equal "#", unbound.inspect assert_equal [[:opt, :arg]], unbound.parameters obj = b.new @@ -1281,7 +1281,7 @@ class TestMethod < Test::Unit::TestCase a.remove_method(:foo) - assert_equal "#", unbound.inspect + assert_equal "#", unbound.inspect assert_equal [[:opt, :arg]], unbound.parameters assert_equal a0_foo, unbound.super_method @@ -1289,7 +1289,7 @@ class TestMethod < Test::Unit::TestCase assert_equal 1, unbound.bind_call(obj) assert_include b.instance_methods(false), :foo - assert_equal "#", b.instance_method(:foo).inspect + assert_equal "#", b.instance_method(:foo).inspect end def test_zsuper_method_redefined_bind_call -- cgit v1.2.3