diff options
author | Jean Boussier <[email protected]> | 2025-03-13 13:29:37 +0100 |
---|---|---|
committer | Jean Boussier <[email protected]> | 2025-03-14 09:51:57 +0100 |
commit | de48e47ddf78aba02fd9623bc7ce685540a10743 () | |
tree | e4e7d409eb5d8343b85dc2628f5e1c8e7782b2dc /vm_insnhelper.c | |
parent | dd7deef338d843c8d866ddc279854068b39bfeb9 (diff) |
Invoke `inherited` callbacks before `const_added`
[Misc #21143] Conceptually this makes sense and is more consistent with using the `Name = Class.new(Superclass)` alternative method. However the new class is still named before `inherited` is called.
Notes: Merged: https://.com/ruby/ruby/pull/12927
-rw-r--r-- | vm_insnhelper.c | 18 |
1 files changed, 7 insertions, 11 deletions
@@ -5745,29 +5745,25 @@ vm_check_if_module(ID id, VALUE mod) } static VALUE -declare_under(ID id, VALUE cbase, VALUE c) -{ - rb_set_class_path_string(c, cbase, rb_id2str(id)); - rb_const_set(cbase, id, c); - return c; -} - -static VALUE vm_declare_class(ID id, rb_num_t flags, VALUE cbase, VALUE super) { /* new class declaration */ VALUE s = VM_DEFINECLASS_HAS_SUPERCLASS_P(flags) ? super : rb_cObject; - VALUE c = declare_under(id, cbase, rb_define_class_id(id, s)); rb_define_alloc_func(c, rb_get_alloc_func(c)); rb_class_inherited(s, c); return c; } static VALUE vm_declare_module(ID id, VALUE cbase) { - /* new module declaration */ - return declare_under(id, cbase, rb_module_new()); } NORETURN(static void unmatched_redefinition(const char *type, VALUE cbase, ID id, VALUE old)); |