ruby-changes:48825
From: marcandre <ko1@a...>
Date: Thu, 30 Nov 2017 02:48:02 +0900 (JST)
Subject: [ruby-changes:48825] marcandRe: r60942 (trunk): Make Module#{define|alias|undef|remove}_method public [#14133]
marcandre 2017-11-30 02:47:59 +0900 (Thu, 30 Nov 2017) New Revision: 60942 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60942 Log: Make Module#{define|alias|undef|remove}_method public [#14133] Modified files: trunk/NEWS trunk/proc.c trunk/test/ruby/test_module.rb trunk/vm_method.c Index: NEWS =================================================================== --- NEWS (revision 60941) +++ NEWS (revision 60942) @@ -79,6 +79,7 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L79 * Module * Module#attr, attr_accessor, attr_reader, attr_writer are now public [#14132] + * Module#define_method, alias_method, undef_method, remove_method are now public [#14133] * Net::HTTP Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 60941) +++ test/ruby/test_module.rb (revision 60942) @@ -2038,6 +2038,10 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L2038 attr_accessor attr_reader attr_writer + define_method + alias_method + undef_method + remove_method ] assert_equal public_methods.sort, (Module.public_methods & public_methods).sort end @@ -2104,9 +2108,9 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L2108 def test_visibility_by_public_class_method bug8284 = '[ruby-core:54404] [Bug #8284]' - assert_raise(NoMethodError) {Object.define_method} - Module.new.public_class_method(:define_method) - assert_raise(NoMethodError, bug8284) {Object.define_method} + assert_raise(NoMethodError) {Object.remove_const} + Module.new.public_class_method(:remove_const) + assert_raise(NoMethodError, bug8284) {Object.remove_const} end def test_include_module_with_constants_does_not_invalidate_method_cache Index: vm_method.c =================================================================== --- vm_method.c (revision 60941) +++ vm_method.c (revision 60942) @@ -2085,9 +2085,9 @@ Init_eval_method(void) https://github.com/ruby/ruby/blob/trunk/vm_method.c#L2085 rb_define_method(rb_mKernel, "respond_to?", obj_respond_to, -1); rb_define_method(rb_mKernel, "respond_to_missing?", obj_respond_to_missing, 2); - rb_define_private_method(rb_cModule, "remove_method", rb_mod_remove_method, -1); - rb_define_private_method(rb_cModule, "undef_method", rb_mod_undef_method, -1); - rb_define_private_method(rb_cModule, "alias_method", rb_mod_alias_method, 2); + rb_define_method(rb_cModule, "remove_method", rb_mod_remove_method, -1); + rb_define_method(rb_cModule, "undef_method", rb_mod_undef_method, -1); + rb_define_method(rb_cModule, "alias_method", rb_mod_alias_method, 2); rb_define_private_method(rb_cModule, "public", rb_mod_public, -1); rb_define_private_method(rb_cModule, "protected", rb_mod_protected, -1); rb_define_private_method(rb_cModule, "private", rb_mod_private, -1); Index: proc.c =================================================================== --- proc.c (revision 60941) +++ proc.c (revision 60942) @@ -3164,7 +3164,7 @@ Init_Proc(void) https://github.com/ruby/ruby/blob/trunk/proc.c#L3164 /* Module#*_method */ rb_define_method(rb_cModule, "instance_method", rb_mod_instance_method, 1); rb_define_method(rb_cModule, "public_instance_method", rb_mod_public_instance_method, 1); - rb_define_private_method(rb_cModule, "define_method", rb_mod_define_method, -1); + rb_define_method(rb_cModule, "define_method", rb_mod_define_method, -1); /* Kernel */ rb_define_method(rb_mKernel, "define_singleton_method", rb_obj_define_method, -1); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/