In what cases are objects like MutableList automat...
# kotlin-native
j
In what cases are objects like MutableList automatically frozen? I have a frozen array inside a mutable list but I cannot find the cause. Is there an easy way to debug it?
k
The mutable is frozen, or you have a list with a frozen array in it?
Top level objects are frozen, as are companion objects (pretty sure)
o
Please call
ensureNeverFrozen
on objects you would like never frozen
j
Ah that solves it!! It throws an error where the freeze operation is called. It seems it was called through an atomicLazy() higher up which freezes everything in the lambda. (Making my multiplatform code native compatible so was hitting a failure on an existing complex integration test)
Thanks! 😄
k
@olonho Was playing around with ensureNeverFrozen. Found an interesting situation and wondering if this is intended. If the target of ensureNeverFrozen is nested in an object graph it'll fail on a freeze call to parent, but if you call ensureNeverFrozen on an object and call freeze on it directly, it appears to work.
o
indeed, it looks like a bug
k
👍