darkmoon_uk03/17/2021, 7:15 AM
...while adding an element to a
Caused by: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlin.collections.HashMap@33944e8
. However: • The Set is created while on the main thread • The Set is only ever accessed from the main thread (I've asserted these points with checks on
at every relevant point) • The top level object under which the Set (indirectly) resides, is marked
...which other restriction am I missing!? Is there a way to determine at what point an object is being frozen?
Tijl03/17/2021, 7:19 AM
after creating it, and then get an exception when something tries to freeze it
darkmoon_uk03/17/2021, 7:19 AM
will be frozen unless marked
. Would it be reasonable for the docs to advise that applying
should be considered a sensible 'default' for newcomers.
russhwolf03/17/2021, 12:48 PM
by default would have it's own set of confusion and drawbacks. Anytime you access it from a background thread, none of the state you've set in the main thread will be present, but it might not be obvious that something's wrong because nothing will throw.
darkmoon_uk03/17/2021, 1:48 PM
be an actual language default; agree it could cause some serious confusion... but rather a suggested way to start for those wanting to avoid the potentially greater complications of object freezing.