Kotlin / kotlinx.collections.immutable

Immutable persistent collections for Kotlin
Apache License 2.0
1.16k stars 59 forks source link

Fix for #109 #110

Closed belyaev-mikhail closed 3 years ago

belyaev-mikhail commented 3 years ago

Seems like some logic here is broken: mutableUpdateNodeAtIndex expects newNode to be newly-created, but mutableReplaceNode does not check for it properly (newNode may be equal to targetNode, which may be any node of any builder previously created)

belyaev-mikhail commented 3 years ago

Maybe the idea was to check newNode.ownedBy instead of ownedBy? Anyway, removing the check fixes the test.

belyaev-mikhail commented 3 years ago

I'd love to provide a regression test, but have no idea how to reproduce this outside the node implementation. Even random test triggers this exclusively on JVM, because JVM implementation of these tests (and no other platform) actually calls builder's remove(key, value) method due to overloading witchcrafting, no other tests seem to call it under such stressful conditions.