From de48e47ddf78aba02fd9623bc7ce685540a10743 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Thu, 13 Mar 2025 13:29:37 +0100 Subject: 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. --- class.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'class.c') diff --git a/class.c b/class.c index b39e693837..5d13cbaf7d 100644 --- a/class.c +++ b/class.c @@ -1004,8 +1004,8 @@ rb_define_class(const char *name, VALUE super) } klass = rb_define_class_id(id, super); rb_vm_register_global_object(klass); - rb_const_set(rb_cObject, id, klass); rb_class_inherited(super, klass); + rb_const_set(rb_cObject, id, klass); return klass; } @@ -1043,8 +1043,8 @@ rb_define_class_id_under_no_pin(VALUE outer, ID id, VALUE super) } klass = rb_define_class_id(id, super); rb_set_class_path_string(klass, outer, rb_id2str(id)); - rb_const_set(outer, id, klass); rb_class_inherited(super, klass); + rb_const_set(outer, id, klass); return klass; } -- cgit v1.2.3