I have an expect class: ```public expect class Cop...
# k2-adopters
e
I have an expect class:
Copy code
public expect class CopyOnWriteArrayList<E>() : MutableList<E> {
  public constructor(elements: Collection<E>)
  
  ... all the methods from MutableList. Not sure why but K2 requires overriding them explicitly
}
With an actual typealias per platform:
Copy code
public actual typealias CopyOnWriteArrayList<E> = ArrayList<E> // Native
public actual typealias CopyOnWriteArrayList<E> = java.util.concurrent.CopyOnWriteArrayList<E> // JVM
public actual typealias CopyOnWriteArrayList<E> = ArrayList<E> // WASM WASI
public actual typealias CopyOnWriteArrayList<E> = ArrayList<E> // JS and WASM JS
K2 complains with this error:
Copy code
e: file:///C:/Users/.../CopyOnWriteArrayList.kt:5:1 Expect declaration `CopyOnWriteArrayList` doesn't match actual `CopyOnWriteArrayList` because some expected members have no actual ones
But without telling me which expected members. Is this a bug?
d
cc @bobko, @Roman Efremov
r
@Edoardo Luppi could you tell please, which compiler version are you using (2.0.0-Beta3/earlier)? And on which platform it is reported (JVM/Native/other)?
e
@Roman Efremov forgot to try it with 2.0.0-Beta3. I'm using 1.9.22 with experimental K2 enabled. Will let you know if it happens the same in the latest one. The error is reported on the common source set btw.
Ahhh nice, with Beta3 I get a much better error message.
Copy code
e: file:///C:/Users/edoardo.luppi/IdeaProjects/antlr-kotlin/antlr-kotlin-runtime/src/jvmMain/kotlin/com/strumenta/antlrkotlin/runtime/IdentityHashMap.kt:8:25 'actual typealias IdentityHashMap<K, V> = IdentityHashMap<K, V>' has no corresponding members for expected class members:

    expect val values: MutableCollection<V>

e: file:///C:/Users/edoardo.luppi/IdeaProjects/antlr-kotlin/antlr-kotlin-runtime/src/jvmMain/kotlin/com/strumenta/antlrkotlin/runtime/WeakHashMap.kt:8:25 'actual typealias WeakHashMap<K, V> = WeakHashMap<K, V>' has no corresponding members for expected class members:

    expect val values: MutableCollection<V>
I guess Kotlin is looking for a
getValues()
method, but the Java classes have
values()
(Not sure if you consider it a bug or not tho)
r
This is known problem (KT-63624), should be fixed in 2.0.0-Beta4
Thanks for the report!
e
Oh nice, thanks!