ruby-changes:37566
From: naruse <ko1@a...>
Date: Thu, 19 Feb 2015 16:19:44 +0900 (JST)
Subject: [ruby-changes:37566] naruse:r49647 (ruby_2_2): merge revision(s) 49480, 49493: [Backport #10765]
naruse 2015-02-19 16:19:33 +0900 (Thu, 19 Feb 2015) New Revision: 49647 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49647 Log: merge revision(s) 49480,49493: [Backport #10765] * vm_method.c (remove_method): When remove refined method, raise a NameError if the method is not defined in refined class. But if the method is defined in refined class, it should keep refined method and remove original method. Patch by Seiei Higa. [ruby-core:67722] [Bug #10765] * class.c (method_entry_i, class_instance_method_list, rb_obj_singleton_methods): should not include methods of superclasses if recur is false. [ruby-dev:48854] [Bug #10826] Modified directories: branches/ruby_2_2/ Modified files: branches/ruby_2_2/ChangeLog branches/ruby_2_2/test/ruby/test_refinement.rb branches/ruby_2_2/version.h branches/ruby_2_2/vm_method.c Index: ruby_2_2/ChangeLog =================================================================== --- ruby_2_2/ChangeLog (revision 49646) +++ ruby_2_2/ChangeLog (revision 49647) @@ -1,3 +1,21 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1 +Thu Feb 19 16:14:04 2015 Shugo Maeda <shugo@r...> + + * class.c (method_entry_i, class_instance_method_list, + rb_obj_singleton_methods): should not include methods of + superclasses if recur is false. [ruby-dev:48854] [Bug #10826] + +Thu Feb 19 16:14:04 2015 Shugo Maeda <shugo@r...> + + * vm_method.c (remove_method): When remove refined + method, raise a NameError if the method is not + defined in refined class. + + But if the method is defined in refined class, + it should keep refined method and remove original + method. + + Patch by Seiei Higa. [ruby-core:67722] [Bug #10765] + Thu Feb 19 16:07:03 2015 Seiei Higa <hanachin@g...> * proc.c (rb_obj_singleton_method): Kernel#singleton_method should Index: ruby_2_2/vm_method.c =================================================================== --- ruby_2_2/vm_method.c (revision 49646) +++ ruby_2_2/vm_method.c (revision 49647) @@ -766,10 +766,12 @@ remove_method(VALUE klass, ID mid) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm_method.c#L766 if (!st_lookup(RCLASS_M_TBL(klass), mid, &data) || !(me = (rb_method_entry_t *)data) || - (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF)) { + (!me->def || me->def->type == VM_METHOD_TYPE_UNDEF) || + UNDEFINED_REFINED_METHOD_P(me->def)) { rb_name_error(mid, "method `%"PRIsVALUE"' not defined in %"PRIsVALUE, rb_id2str(mid), rb_class_path(klass)); } + key = (st_data_t)mid; st_delete(RCLASS_M_TBL(klass), &key, &data); @@ -777,6 +779,10 @@ remove_method(VALUE klass, ID mid) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm_method.c#L779 rb_clear_method_cache_by_class(klass); rb_unlink_method_entry(me); + if (me->def->type == VM_METHOD_TYPE_REFINED) { + rb_add_refined_method_entry(klass, mid); + } + CALL_METHOD_HOOK(self, removed, mid); } Index: ruby_2_2/version.h =================================================================== --- ruby_2_2/version.h (revision 49646) +++ ruby_2_2/version.h (revision 49647) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1 #define RUBY_VERSION "2.2.0" #define RUBY_RELEASE_DATE "2015-02-19" -#define RUBY_PATCHLEVEL 57 +#define RUBY_PATCHLEVEL 58 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 2 Index: ruby_2_2/test/ruby/test_refinement.rb =================================================================== --- ruby_2_2/test/ruby/test_refinement.rb (revision 49646) +++ ruby_2_2/test/ruby/test_refinement.rb (revision 49647) @@ -1310,6 +1310,58 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_refinement.rb#L1310 end; end + def test_remove_refined_method + assert_separately([], <<-"end;") + bug10765 = '[ruby-core:67722] [Bug #10765]' + + class C + def foo + "C#foo" + end + end + + module RefinementBug + refine C do + def foo + "RefinementBug#foo" + end + end + end + + using RefinementBug + + class C + remove_method :foo + end + + assert_equal("RefinementBug#foo", C.new.foo, bug10765) + end; + end + + def test_remove_undefined_refined_method + assert_separately([], <<-"end;") + bug10765 = '[ruby-core:67722] [Bug #10765]' + + class C + end + + module RefinementBug + refine C do + def foo + end + end + end + + using RefinementBug + + assert_raise(NameError, bug10765) { + class C + remove_method :foo + end + } + end; + end + module NotIncludeSuperclassMethod class X def foo Property changes on: ruby_2_2 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r49480 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/