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.
This commit is contained in:
Jean Boussier 2025-03-13 13:29:37 +01:00
parent dd7deef338
commit de48e47ddf
Notes: git 2025-03-14 08:52:23 +00:00
7 changed files with 72 additions and 21 deletions

View file

@ -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;
}