Kotlin / kotlinx.collections.immutable

Immutable persistent collections for Kotlin
Apache License 2.0
1.12k stars 56 forks source link

Bug in PersistentList - list is broken after removeAll call #92

Closed maio closed 3 years ago

maio commented 3 years ago

It only happens in certain situations. It can be reproduced using following test:

class PersistentListTest {
    @Test
    fun `persistent list fails`() {
        var xs = persistentListOf(
            *(1..1885).map { it }.toTypedArray()
        )

        xs = xs.removeAll(
            (1..1837).map { it }
        )

        println(xs.size)

        xs.forEach {
            print(it)
        }
    }
}

print(it.i) fails with exception

java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class java.lang.Number
 ([Ljava.lang.Object; and java.lang.Number are in module java.base of loader 'bootstrap')
qurbonzoda commented 3 years ago

Fixing commit is now in master and will part of the coming release. Thank you for your bug report!