summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-05 14:21:12 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-02-05 14:21:12 +0000
commit3b3d4b6bf5ea028246a432c4a9874b755b1438a0 (patch)
tree47508d5e4735d0837eb39cce42422c2c362a0577 /vm_method.c
parent652e695a384563e0f96adc70d16ff53a3567451a (diff)
merge revision(s) 61484: [Backport #14232]
vm_method.c: fix super in refined module * vm_method.c (rb_method_entry_complement_defined_class): clone the original method entry of refined module instance method with the active ICLASS, to track super method chain. [ruby-dev:50390] [Bug #14232] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/vm_method.c b/vm_method.c
index c463162d3b..e0088d0016 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -410,10 +410,33 @@ rb_method_entry_clone(const rb_method_entry_t *src_me)
const rb_callable_method_entry_t *
rb_method_entry_complement_defined_class(const rb_method_entry_t *src_me, ID called_id, VALUE defined_class)
{
- rb_method_entry_t *me = rb_method_entry_alloc(called_id, src_me->owner, defined_class,
- method_definition_addref_complement(src_me->def));
+ rb_method_definition_t *def = src_me->def;
+ rb_method_entry_t *me;
+ struct {
+ const struct rb_method_entry_struct *orig_me;
+ VALUE owner;
+ } refined = {0};
+
+ if (!src_me->defined_class &&
+ def->type == VM_METHOD_TYPE_REFINED &&
+ def->body.refined.orig_me) {
+ const rb_method_entry_t *orig_me =
+ rb_method_entry_clone(def->body.refined.orig_me);
+ RB_OBJ_WRITE((VALUE)orig_me, &orig_me->defined_class, defined_class);
+ refined.orig_me = orig_me;
+ refined.owner = orig_me->owner;
+ def = NULL;
+ }
+ else {
+ def = method_definition_addref_complement(def);
+ }
+ me = rb_method_entry_alloc(called_id, src_me->owner, defined_class, def);
METHOD_ENTRY_FLAGS_COPY(me, src_me);
METHOD_ENTRY_COMPLEMENTED_SET(me);
+ if (!def) {
+ def = method_definition_create(VM_METHOD_TYPE_REFINED, called_id);
+ method_definition_set(me, def, &refined);
+ }
VM_ASSERT(RB_TYPE_P(me->owner, T_MODULE));