ruby-changes:32119
From: nobu <ko1@a...>
Date: Sat, 14 Dec 2013 13:02:12 +0900 (JST)
Subject: [ruby-changes:32119] nobu:r44198 (trunk): proc.c: method by respond_to_missing?
nobu 2013-12-14 13:02:00 +0900 (Sat, 14 Dec 2013) New Revision: 44198 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=44198 Log: proc.c: method by respond_to_missing? * proc.c (mnew_from_me): method by respond_to_missing? should be owned by the original class. Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_method.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 44197) +++ ChangeLog (revision 44198) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Dec 14 13:01:45 2013 Nobuyoshi Nakada <nobu@r...> + + * proc.c (mnew_from_me): method by respond_to_missing? should be + owned by the original class. + Sat Dec 14 11:55:31 2013 Nobuyoshi Nakada <nobu@r...> * lib/scanf.rb (IO#scanf): fix mistaken use of rescue modifier. Index: proc.c =================================================================== --- proc.c (revision 44197) +++ proc.c (revision 44198) @@ -1139,6 +1139,7 @@ mnew_from_me(rb_method_entry_t *me, VALU https://github.com/ruby/ruby/blob/trunk/proc.c#L1139 if (obj != Qundef && !rb_method_basic_definition_p(klass, rmiss)) { if (RTEST(rb_funcall(obj, rmiss, 2, sym, scope ? Qfalse : Qtrue))) { me = 0; + defined_class = klass; goto gen_method; } Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 44197) +++ test/ruby/test_method.rb (revision 44198) @@ -189,6 +189,17 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L189 assert_equal(c, c2.instance_method(:foo).owner) end + def test_owner_missing + c = Class.new do + def respond_to_missing?(name, bool) + name == :foo + end + end + c2 = Class.new(c) + assert_equal(c, c.new.method(:foo).owner) + assert_equal(c2, c2.new.method(:foo).owner) + end + def test_receiver_name_owner o = Object.new def o.foo; end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/