ruby-changes:30824
From: nobu <ko1@a...>
Date: Tue, 10 Sep 2013 12:39:41 +0900 (JST)
Subject: [ruby-changes:30824] nobu:r42903 (trunk): class.c: exclude refined methods
nobu 2013-09-10 12:39:31 +0900 (Tue, 10 Sep 2013) New Revision: 42903 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42903 Log: class.c: exclude refined methods * class.c (method_entry_i): should exclude refined methods from instance method list. [ruby-core:57080] [Bug #8881] Modified files: trunk/ChangeLog trunk/class.c trunk/test/ruby/test_refinement.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42902) +++ ChangeLog (revision 42903) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Sep 10 12:39:17 2013 Nobuyoshi Nakada <nobu@r...> + + * class.c (method_entry_i): should exclude refined methods from + instance method list. [ruby-core:57080] [Bug #8881] + Tue Sep 10 12:05:04 2013 Kazuhiro NISHIYAMA <zn@m...> * io.c (rb_f_printf): [DOC] add missing parenthesis in rdoc. Index: class.c =================================================================== --- class.c (revision 42902) +++ class.c (revision 42903) @@ -1121,6 +1121,10 @@ method_entry_i(st_data_t key, st_data_t https://github.com/ruby/ruby/blob/trunk/class.c#L1121 st_table *list = (st_table *)data; long type; + if (me && me->def->type == VM_METHOD_TYPE_REFINED) { + me = rb_resolve_refined_method(Qnil, me, NULL); + if (!me) return ST_CONTINUE; + } if (!st_lookup(list, key, 0)) { if (UNDEFINED_METHOD_ENTRY_P(me)) { type = -1; /* none */ Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 42902) +++ test/ruby/test_refinement.rb (revision 42903) @@ -1005,6 +1005,17 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1005 end; end + def test_instance_methods + bug8881 = '[ruby-core:57080] [Bug #8881]' + assert_not_include(Foo.instance_methods(false), :z, bug8881) + assert_not_include(FooSub.instance_methods(true), :z, bug8881) + end + + def test_method_defined + assert_not_send([Foo, :method_defined?, :z]) + assert_not_send([FooSub, :method_defined?, :z]) + end + private def eval_using(mod, s) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/