-
Notifications
You must be signed in to change notification settings - Fork 668
Closed
Description
Describe the bug
Currently if we provide @serializable(with = CustomSerializer) annotation then we no longer have access to original generated serializer. Which is fine in most cases, but it is critical when we deal with polymotphism. The main issue is that we run into dependency cycle.
To Reproduce
The following code crashes the app with NPE
@Serializable(with = MediaImageSerializer::class)
@SerialName("image")
data class MediaImage(...)
object MediaImageSerializer : JsonTransformingSerializer<MediaImage>(MediaImage.serializer())
The problem here is that we can't avoid @Serializable(with = MediaImageSerializer::class) here. Because the object that contains mediaImage doesn't know its type:
@Serializable
class Template(medias: List<@Serializable with [we don't know which serializer to use] Media>)
Expected behavior
We need to be able to use original generated serializer
Environment
- Kotlin version: 1.4.30-RC
- Library version: 1.0.1
- Kotlin platforms: JVM
Metadata
Metadata
Assignees
Labels
No labels