summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-25 06:01:25 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-02-25 06:01:25 +0000
commit94ec0a64197ab7a0edfb6599074df0a2920607e4 (patch)
tree687082f0a7811e404327e0ce8dac4b1f60621b7c /vm_method.c
parent24bb5756b1e61279c0be437c10210ad26e951ffd (diff)
merge revision(s) 49222,49480,49493: [Backport #10765] [Backport #1010826]
method.h: UNDEFINED_REFINED_METHOD_P * method.h (UNDEFINED_REFINED_METHOD_P): macro to tell if refined original method is defined. * 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@49738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/vm_method.c b/vm_method.c
index b836d1ddde..6982e58760 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -690,10 +690,12 @@ remove_method(VALUE klass, ID mid)
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 `%s' not defined in %s",
rb_id2name(mid), rb_class2name(klass));
}
+
key = (st_data_t)mid;
st_delete(RCLASS_M_TBL(klass), &key, &data);
@@ -701,6 +703,10 @@ remove_method(VALUE klass, ID mid)
rb_clear_cache_for_undef(klass, mid);
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);
}
@@ -772,8 +778,7 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex)
}
if (UNDEFINED_METHOD_ENTRY_P(me) ||
- (me->def->type == VM_METHOD_TYPE_REFINED &&
- UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) {
+ UNDEFINED_REFINED_METHOD_P(me->def)) {
rb_print_undef(klass, name, 0);
}
@@ -881,8 +886,7 @@ rb_undef(VALUE klass, ID id)
me = search_method(klass, id, 0);
if (UNDEFINED_METHOD_ENTRY_P(me) ||
- (me->def->type == VM_METHOD_TYPE_REFINED &&
- UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) {
+ UNDEFINED_REFINED_METHOD_P(me->def)) {
const char *s0 = " class";
VALUE c = klass;
@@ -1222,8 +1226,7 @@ rb_alias(VALUE klass, ID name, ID def)
orig_me = search_method(klass, def, &defined_class);
if (UNDEFINED_METHOD_ENTRY_P(orig_me) ||
- (orig_me->def->type == VM_METHOD_TYPE_REFINED &&
- UNDEFINED_METHOD_ENTRY_P(orig_me->def->body.orig_me))) {
+ UNDEFINED_REFINED_METHOD_P(orig_me->def)) {
if ((!RB_TYPE_P(klass, T_MODULE)) ||
(orig_me = search_method(rb_cObject, def, 0),
UNDEFINED_METHOD_ENTRY_P(orig_me))) {