From c7770f90bdcac04dad43ab38bef9c415433597cb Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 3 Apr 2018 06:57:43 +0000 Subject: Fix Kernel#singleton_method with Module#Prepend * proc.c (rb_obj_singleton_method): search the method entry from the origin class, for fix prepended modules. [Bug #14658] From: Vasiliy Ermolovich git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63067 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_method.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 0ef913fd78..67c24a8fd8 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -782,6 +782,16 @@ class TestMethod < Test::Unit::TestCase assert_equal(:bar, m.call, feature8391) end + def test_singleton_method_prepend + bug14658 = '[Bug #14658]' + c1 = Class.new + o = c1.new + def o.bar; :bar; end + class << o; prepend Module.new; end + m = assert_nothing_raised(NameError, bug14658) {o.singleton_method(:bar)} + assert_equal(:bar, m.call, bug14658) + end + Feature9783 = '[ruby-core:62212] [Feature #9783]' def assert_curry_three_args(m) -- cgit v1.2.3