Hello, I am trying to use the Stately's Isolate Co...
# kotlin-native
m
Hello, I am trying to use the Stately's Isolate Collections library. However when I'm trying to iterate over an IsoMutableMap, then I get crash saying UnsupportedOperationException("Can't leak mutable reference"). In the IsoMutableMap.kt, this operations is blocked as below. Can someone share why 'entries' can leak mutable reference but not the 'values'? Also, Is there any other way to iterate over the entry set?
Copy code
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
    get() {
        throw UnsupportedOperationException("Can't leak mutable reference")
        // access { IsoMutableSet(fork(it.entries)) }
    }
Thanks!
k
There was a reason. I wrote that ­čÖé
I remember. The default implementation of
MutableMap.MutableEntry
retains a reference to it's parent. Stepping through that would likely try to return an instance of
MutableMap.MutableEntry
across threads, which will crash. To properly implement
entries
, we'd need to wrap the
MutableSet<MutableMap.MutableEntry<K, V>>
result
­čĹŹ 1