Do you have any idea what a “synthetic inheritor” means?
(I still try to extract some sample code that demonstrates the error.)
Platform declaration clash: The following declarations have the same JVM signature (remove(Ljava/lang/Object;)Ljava/lang/Object;):
fun remove(key: K#1 (type parameter of p.X)): V#1 (type parameter of p.X)? defined in p.X
fun remove(key: K#2 (type parameter of p.<synthetic inheritor of X>)): V#2 (type parameter of p.<synthetic inheritor of X>)? defined in p.<synthetic inheritor of X>
The cause is that the compiler treats specially if core collection interfaces are used as a supertype: kotlin/CollectionStubMethodGenerator.kt at master · JetBrains/kotlin · GitHub
My class X
indirectly implements kotlin.collections.Map
and the compiler doesn’t seem to like it
Could you show the code of you class X?
Here is an example code reproducing the same compile error:
interface SimpleMutableMap<K, V> : Map<K, V> {
fun put(key: K, value: V): V?
fun remove(key: K): V?
}
interface SomeInterface
class SimpleMutableHashMap<K, V: SomeInterface> : SimpleMutableMap<K, V> {
override fun put(key: K, value: V): V? {
TODO("not implemented")
}
override fun remove(key: K): V? {
TODO("not implemented")
}
override val entries: Set<Entry<K, V>> get() = TODO("not implemented")
override val keys: Set<K> get() = TODO("not implemented")
override val size: Int get() = TODO("not implemented")
override val values: Collection<V> get() = TODO("not implemented")
override fun containsKey(key: K): Boolean {
TODO("not implemented")
}
override fun containsValue(value: V): Boolean {
TODO("not implemented")
}
override fun get(key: K): V? {
TODO("not implemented")
}
override fun isEmpty(): Boolean {
TODO("not implemented")
}
}
Thanks for the reproducer example. It looks like the following problem:
KT-22191 Unable to declare remove()
method in interface that extends Collection
due to collision with synthetic method