From 4be089c0dd720324730230c1abfe0c200d125359 Mon Sep 17 00:00:00 2001 From: usa Date: Sun, 28 Feb 2021 14:53:21 +0000 Subject: merge revision(s) e02bd0e7: [Backport #15608] Don't display singleton class in Method#inspect unless method defined there Previously, if an object has a singleton class, and you call Object#method on the object, the resulting string would include the object's singleton class, even though the method was not defined in the singleton class. Change this so the we only show the singleton class if the method is defined in the singleton class. Fixes [Bug #15608] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_6@67902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_method.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 3a7186584a..2d615ca53f 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -458,6 +458,14 @@ class TestMethod < Test::Unit::TestCase m.taint assert_predicate(m.inspect, :tainted?, "inspect result should be infected") + + bug15608 = '[ruby-core:91570] [Bug #15608]' + c4 = Class.new(c) + c4.class_eval { alias bar foo } + o = c4.new + o.singleton_class + m4 = o.method(:bar) + assert_equal("#", m4.inspect, bug15608) end def test_callee_top_level -- cgit v1.2.3