diff options
author | John Hawthorn <[email protected]> | 2022-04-15 15:21:10 -0700 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2022-04-16 11:40:56 -0700 |
commit | 7950c4eb2d132fca40d1e9383e8a7240781cc575 (patch) | |
tree | 0bc52106980f58a5ce026fee3d5ff143c1bd274a /class.c | |
parent | e70e7f4ad38abb305342dd4d5a392782597d1f98 (diff) |
Fix class ancestry checks for duped classes
Previously in some when classes were duped (specifically those with a
prepended module), they would not correctly have their "superclasses"
array or depth filled in.
This could cause ancestry checks (like is_a? and Module comparisons) to
return incorrect results.
This happened because rb_mod_init_copy builds origin classes in an order
that doesn't have the super linked list fully connected until it's
finished. This commit fixes the previous issue by calling
rb_class_update_superclasses before returning the cloned class. This is
similar to what's already done in make_metaclass.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5808
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -567,6 +567,8 @@ rb_mod_init_copy(VALUE clone, VALUE orig) else { rb_bug("no origin for class that has origin"); } + + rb_class_update_superclasses(clone); } return clone; |