Generic Interface The following declarations have the same JVM signature

When creating a interface for my mappers:

interface EntityMapper<T, K> {
    fun map(source: T): K
    fun map(source: K): T
}

I’m getting a build error:

Error:(8, 5) Platform declaration clash: The following declarations have the same JVM signature (map(Ljava/lang/Object;)Ljava/lang/Object;):
fun map(source: K): T defined in pt.southbank.room.mappers.EntityMapper
fun map(source: T): K defined in pt.southbank.room.mappers.EntityMapper

why? the methods have different methods.

1 Like

I just ran into the same issue.
Now I understand why some people say Java has poorly designed generics.
It looks like generics are only checked by the compiler but then handled as Object by the JVM.