mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Freeze singleton class, not its origin
Previously, when we froze an object, we froze `RCLASS_ORIGIN(object.singleton_class)`, which didn't freeze `object.singleton_class` when it has some prepended modules. Origin iclass are internal objects and users can't interact with them through Kernel#freeze?, Kernel#freeze, or any mutation method that checks the frozen status. So we shouldn't touch the origin iclasses when the frozen status should be visible. [Bug #19169]
This commit is contained in:
parent
47a5b34aba
commit
bb8afd7265
Notes:
git
2022-12-08 20:58:46 +00:00
2 changed files with 14 additions and 1 deletions
2
class.c
2
class.c
|
@ -2148,7 +2148,7 @@ rb_freeze_singleton_class(VALUE x)
|
|||
/* should not propagate to meta-meta-class, and so on */
|
||||
if (!(RBASIC(x)->flags & FL_SINGLETON)) {
|
||||
VALUE klass = RBASIC_CLASS(x);
|
||||
if (klass && (klass = RCLASS_ORIGIN(klass)) != 0 &&
|
||||
if (klass && // no class when hidden from ObjectSpace
|
||||
FL_TEST(klass, (FL_SINGLETON|FL_FREEZE)) == FL_SINGLETON) {
|
||||
OBJ_FREEZE_RAW(klass);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue