From 5836962f48200c71f5989315b9e2ac4db2b87541 Mon Sep 17 00:00:00 2001 From: shugo Date: Wed, 7 Nov 2012 04:09:51 +0000 Subject: * eval.c (rb_mod_refine): set RMODULE_IS_REFINEMENT to a created refinement module, and don't override method_added. * vm_method.c (rb_method_entry_make): check redefinition of optimized methods when a method is added to a refinement module. [ruby-core:48970] [Bug #7290] * test/ruby/test_refinement.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- eval.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'eval.c') diff --git a/eval.c b/eval.c index 08a5624ba4..bd0f085f9d 100644 --- a/eval.c +++ b/eval.c @@ -1157,21 +1157,6 @@ rb_mod_using(VALUE self, VALUE module) return self; } -void rb_redefine_opt_method(VALUE, ID); - -static VALUE -refinement_module_method_added(VALUE mod, VALUE mid) -{ - ID id = SYM2ID(mid); - ID id_refined_class; - VALUE klass; - - CONST_ID(id_refined_class, "__refined_class__"); - klass = rb_ivar_get(mod, id_refined_class); - rb_redefine_opt_method(klass, id); - return Qnil; -} - static VALUE refinement_module_include(int argc, VALUE *argv, VALUE module) { @@ -1234,12 +1219,11 @@ rb_mod_refine(VALUE module, VALUE klass) mod = rb_hash_lookup(refinements, klass); if (NIL_P(mod)) { mod = rb_module_new(); + FL_SET(mod, RMODULE_IS_REFINEMENT); CONST_ID(id_refined_class, "__refined_class__"); rb_ivar_set(mod, id_refined_class, klass); CONST_ID(id_defined_at, "__defined_at__"); rb_ivar_set(mod, id_defined_at, module); - rb_define_singleton_method(mod, "method_added", - refinement_module_method_added, 1); rb_define_singleton_method(mod, "include", refinement_module_include, -1); rb_using_refinement(cref, klass, mod); -- cgit v1.2.3