aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-17 22:43:35 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-17 22:43:35 +0000
commit81c5bc3d85fc207bbbeb85ed66292c4943ff6a23 (patch)
tree178300a472960f60ed58648893d5d49861ef449c
parent47a31804d68649a90d70c234a8d32f96cb14a9bf (diff)
downloadruby-81c5bc3d85fc207bbbeb85ed66292c4943ff6a23.tar.gz
* vm.c (rb_vm_check_redefinition_opt_method): should check the real
class instead of the origin iclass. [ruby-core:72188] [Bug #11826] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_module.rb16
-rw-r--r--vm.c3
3 files changed, 25 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 0736c872e3..f87a71a43f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Dec 18 07:39:01 2015 Shugo Maeda <shugo@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* vm_args.c (vm_caller_setup_arg_block): remove code for ifunc
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 5356983135..1a852f84a0 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1695,6 +1695,22 @@ class TestModule < Test::Unit::TestCase
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
diff --git a/vm.c b/vm.c
index 3c80cd16aa..2dd2dfc879 100644
--- a/vm.c
+++ b/vm.c
@@ -1400,6 +1400,9 @@ static void
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);