# Platform declaration clash

**URL:** <https://discuss.kotlinlang.org/t/platform-declaration-clash/12613>\
**Category:** Support\
**Created:** [May 6, 2019, 7:50pm UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613 "2019-05-06T19:50:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![snorbi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@snorbi](https://discuss.kotlinlang.org/u/snorbi)\
**Post date:** [May 6, 2019, 7:50pm UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613/1 "2019-05-06T19:50:50Z")

</div>

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>

```

---

<div class="post-metadata">

**Author:** ![snorbi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@snorbi](https://discuss.kotlinlang.org/u/snorbi)\
**Post date:** [May 6, 2019, 8:16pm UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613/2 "2019-05-06T20:16:37Z")

</div>

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](https://github.com/JetBrains/kotlin/blob/master/compiler/backend/src/org/jetbrains/kotlin/codegen/CollectionStubMethodGenerator.kt#L88)  
My `class X` indirectly implements `kotlin.collections.Map` and the compiler doesn’t seem to like it ☹

---

<div class="post-metadata">

**Author:** ![ilya.gorbunov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ilya.gorbunov/32/1645_2.png) [@ilya.gorbunov](https://discuss.kotlinlang.org/u/ilya.gorbunov)\
**Post date:** [May 6, 2019, 8:49pm UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613/3 "2019-05-06T20:49:58Z")

</div>

Could you show the code of you class X?

---

<div class="post-metadata">

**Author:** ![snorbi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@snorbi](https://discuss.kotlinlang.org/u/snorbi)\
**Post date:** [May 7, 2019, 12:13pm UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613/4 "2019-05-07T12:13:43Z")

</div>

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")
    }
}

```

---

<div class="post-metadata">

**Author:** ![ilya.gorbunov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ilya.gorbunov/32/1645_2.png) [@ilya.gorbunov](https://discuss.kotlinlang.org/u/ilya.gorbunov)\
**Post date:** [May 7, 2019, 11:50pm UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613/5 "2019-05-07T23:50:35Z")

</div>

Thanks for the reproducer example. It looks like the following problem:  
[KT-22191](https://youtrack.jetbrains.com/issue/KT-22191) Unable to declare `remove()` method in interface that extends `Collection` due to collision with synthetic method

---

<div class="post-metadata">

**Author:** ![snorbi](https://avatars.discourse-cdn.com/v4/letter/s/94ad74/32.png) [@snorbi](https://discuss.kotlinlang.org/u/snorbi)\
**Post date:** [May 8, 2019, 7:22am UTC](https://discuss.kotlinlang.org/t/platform-declaration-clash/12613/6 "2019-05-08T07:22:54Z")

</div>

Thanks for the info.
