I have my own map type: ```interface EnumMap<K : Enum<K>, out V> : Map<K, V> { ...
o
I have my own map type:
Copy code
interface EnumMap<K : Enum<K>, out V> : Map<K, V> {
    override operator fun get(key: K): V
}

interface MutableEnumMap<K : Enum<K>, V> : EnumMap<K, V> {
    operator fun set(key: K, value: V)
}
and its corresponding implementation:
Copy code
@Serializable
class MutableEnumMapImpl<K : Enum<K>, V> : MutableEnumMap<K, V> {
    // ...
}
I also have a custom
KSerializer
for the base
EnumMap
type that basically mimics the built-in map serializer with some additional logic, but I can't figure out how to register it in my
SerializersModule
so when it sees a
MutableEnumMapImpl
it serializes it using it
Copy code
class EnumMapSerializer<K : Enum<K>, V>(
    private val keySerializer: KSerializer<K>,
    private val valueSerializer: KSerializer<V>,
) : KSerializer<EnumMap<K, V>> {
    // ...
}
Any help would be greatly appreciated!
I have managed to do this by changing my interfaces to be abstract classes and setting
@Serializable(EnumMapSetializer::class)
to the
EnumMap
abstract class, and it seems to work, but I would like to keep these as interfaces if possible.