Project

General

Profile

Actions

Bug #20319

open

Singleton class is being frozen lazily in some cases

Added by andrykonchin (Andrew Konchin) 9 months ago. Updated 6 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:117027]

Description

I've noticed suspicious behaviour (it doesn't affect anything in practice for me though) when an object becomes frozen only its own singleton class becomes frozen immediately.

A singleton class of the object immediate singleton class becomes frozen lazily after #singleton_class method call:

o = Object.new
klass = o.singleton_class.singleton_class

o.freeze

puts klass.frozen?                              # false <== here we expect true
puts o.singleton_class.singleton_class.frozen?  # true
puts klass.frozen?                              # true

I would expect all created (and visible to user) singleton classes in an object singleton classes chain to become frozen immediately when the object gets frozen.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0