ruby-changes:27172
From: nobu <ko1@a...>
Date: Wed, 13 Feb 2013 18:39:35 +0900 (JST)
Subject: [ruby-changes:27172] nobu:r39224 (trunk): proc.c: skip prepends
nobu 2013-02-13 18:38:49 +0900 (Wed, 13 Feb 2013) New Revision: 39224 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39224 Log: proc.c: skip prepends * proc.c (mnew): skip prepending modules and return the method bound on the given class. [ruby-core:52160] [Bug #7836] Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_method.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 39223) +++ ChangeLog (revision 39224) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Feb 13 18:37:50 2013 Nobuyoshi Nakada <nobu@r...> + + * proc.c (mnew): skip prepending modules and return the method bound + on the given class. [ruby-core:52160] [Bug #7836] + Wed Feb 13 18:11:59 2013 Nobuyoshi Nakada <nobu@r...> * proc.c (method_original_name): new methods Method#original_name and Index: proc.c =================================================================== --- proc.c (revision 39223) +++ proc.c (revision 39224) @@ -941,6 +941,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALU https://github.com/ruby/ruby/blob/trunk/proc.c#L941 rb_method_flag_t flag = NOEX_UNDEF; again: + if (klass) klass = RCLASS_ORIGIN(klass); me = rb_method_entry_without_refinements(klass, id, &defined_class); if (UNDEFINED_METHOD_ENTRY_P(me)) { ID rmiss = rb_intern("respond_to_missing?"); Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 39223) +++ test/ruby/test_method.rb (revision 39224) @@ -534,4 +534,31 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L534 assert_equal(x.singleton_class, x.method(:bar).owner) assert(x.method(:foo) != x.method(:bar), bug7613) end + + def test_included + m = Module.new { + def foo + end + } + c = Class.new { + def foo + end + include m + } + assert_equal(c, c.instance_method(:foo).owner) + end + + def test_prepended + bug7836 = '[ruby-core:52160] [Bug #7836]' + m = Module.new { + def foo + end + } + c = Class.new { + def foo + end + prepend m + } + assert_equal(c, c.instance_method(:foo).owner, bug7836) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/