ruby-changes:41098
From: shugo <ko1@a...>
Date: Fri, 18 Dec 2015 07:43:57 +0900 (JST)
Subject: [ruby-changes:41098] shugo:r53173 (trunk): * vm.c (rb_vm_check_redefinition_opt_method): should check the real
shugo 2015-12-18 07:43:35 +0900 (Fri, 18 Dec 2015) New Revision: 53173 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53173 Log: * vm.c (rb_vm_check_redefinition_opt_method): should check the real class instead of the origin iclass. [ruby-core:72188] [Bug #11826] Modified files: trunk/ChangeLog trunk/test/ruby/test_module.rb trunk/vm.c Index: ChangeLog =================================================================== --- ChangeLog (revision 53172) +++ ChangeLog (revision 53173) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri Dec 18 07:39:01 2015 Shugo Maeda <shugo@r...> + + * vm.c (rb_vm_check_redefinition_opt_method): should check the real + class instead of the origin iclass. + [ruby-core:72188] [Bug #11826] + Thu Dec 17 22:13:10 2015 Shugo Maeda <shugo@r...> * vm_args.c (vm_caller_setup_arg_block): remove code for ifunc Index: vm.c =================================================================== --- vm.c (revision 53172) +++ vm.c (revision 53173) @@ -1400,6 +1400,9 @@ static void https://github.com/ruby/ruby/blob/trunk/vm.c#L1400 rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass) { st_data_t bop; + if (RB_TYPE_P(klass, T_ICLASS) && FL_TEST(klass, RICLASS_IS_ORIGIN)) { + klass = RBASIC_CLASS(klass); + } if (me->def->type == VM_METHOD_TYPE_CFUNC) { if (st_lookup(vm_opt_method_table, (st_data_t)me, &bop)) { int flag = vm_redefinition_check_flag(klass); Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 53172) +++ test/ruby/test_module.rb (revision 53173) @@ -1695,6 +1695,22 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1695 assert_equal(0, 1 / 2) end + def test_redefine_optmethod_after_prepend + bug11826 = '[ruby-core:72188] [Bug #11826]' + assert_separately [], %{ + module M + end + class Fixnum + prepend M + def /(other) + quo(other) + end + end + assert_equal(1 / 2r, 1 / 2, "#{bug11826}") + }, ignore_stderr: true + assert_equal(0, 1 / 2) + end + def test_prepend_visibility bug8005 = '[ruby-core:53106] [Bug #8005]' c = Class.new do -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/