Multiplatform expect/actual bug in 1.9.0 which is fixed in K2

I have a very simple testcase:

// common
internal expect abstract class ListBackedSet<T>() : Set<T>, AbstractList<T> {}
// js
internal actual abstract class ListBackedSet<T> actual constructor() : Set<T>, AbstractList<T>()
// jvm
internal actual abstract class ListBackedSet<T> actual constructor() : Set<T>, AbstractList<T>() {
  override fun spliterator(): Spliterator<T> = (this as AbstractList<T>).spliterator()
}

With Kotlin 1.9.0 I get two errors (bolding is mine)

Class ‘ListBackedSet’ must override public open fun spliterator(): Spliterator<T!> defined in kotlin.collections.Set because it inherits many implementations of it
Class ‘ListBackedSet’ must override public open fun spliterator(): Spliterator<T!> defined in kotlin.collections.Set because it inherits multiple interface methods of it

If I add kotlin.experimental.tryK2=true to my gradle.properties, it compiles and runs great.

2 Likes

Just confirmed bug is also present in 1.8.22. I also reported it on Youtrack.