summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorKoichi Sasada <[email protected]>2024-10-10 06:01:49 +0900
committerKoichi Sasada <[email protected]>2024-10-10 06:31:57 +0900
commita838f980f599d95ccf344157f7074e997af31f48 (patch)
treec52ed695f1a63b9ce6db6b7d6dd869705eec5740 /vm_method.c
parentd0bff661d65451065cc1132db25a2da2ecc87feb (diff)
`me->defined_class` should be T_CLASS/T_ICLASS
`me->defined_class` will be used for ancestor searching so that it should be T_CLASS or T_ICLASS. This patch will resoleve https://github.com/ruby/ruby/pull/11715
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/11859
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/vm_method.c b/vm_method.c
index bda3837f74..4eb074bbd8 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -759,6 +759,9 @@ static rb_method_entry_t *
rb_method_entry_alloc(ID called_id, VALUE owner, VALUE defined_class, rb_method_definition_t *def, bool complement)
{
if (def) method_definition_addref(def, complement);
+ VM_ASSERT(!defined_class ||
+ NIL_P(defined_class) || // negative cache
+ RB_TYPE_P(defined_class, T_CLASS) || RB_TYPE_P(defined_class, T_ICLASS));
rb_method_entry_t *me = IMEMO_NEW(rb_method_entry_t, imemo_ment, defined_class);
*((rb_method_definition_t **)&me->def) = def;
me->called_id = called_id;
@@ -874,8 +877,9 @@ make_method_entry_refined(VALUE owner, rb_method_entry_t *me)
rb_vm_check_redefinition_opt_method(me, me->owner);
struct rb_method_entry_struct *orig_me =
- rb_method_entry_alloc(me->called_id, me->owner,
- me->defined_class ? me->defined_class : owner,
+ rb_method_entry_alloc(me->called_id,
+ me->owner,
+ me->defined_class,
me->def,
true);
METHOD_ENTRY_FLAGS_COPY(orig_me, me);