I have a generic class `Id<T>` where `T` is ...
# serialization
a
I have a generic class
Id<T>
where
T
is not actually used for serialization/deserialization. I have written a custom serializer for it that I have declared on the class (
@Serializable(with = IdSerializer::class) Id<T> {…}
). The custom serializer is declared as
KSerializer<Id<*>>
and it does not take any parameter. So far it works well, except that if I used it with a parameter that is not serializable (e.g.,
Id<User>
), the compiler complains and I have to add a
@Contextual
annotation to the parameter. Is there a way to specify that the parameter is ignored? (for instance, using an annotation)
d
This seems like a bug. If your custom serialiser is not generic then the plug-in just ignore the generic parameter.
a
I have made a minimal repository to reproduce: https://github.com/alightgoesout/kotlinx-serialization-test If you confirm this is not the expected behavior I will open an issue.