Loney Chou
07/05/2023, 1:52 AM@Serializable(ASerializer::class)
sealed class A
@Serializable
class B<T : A> : A()
object ASerializer : KSerializer<A> {
@OptIn(ExperimentalSerializationApi::class, InternalSerializationApi::class)
override val descriptor: SerialDescriptor = buildSerialDescriptor(
serialName = "A",
kind = PolymorphicKind.SEALED
) {
element(
elementName = "B",
descriptor = /* ... */ // What should I pass in here?
)
}
override fun serialize(encoder: Encoder, value: A) {
TODO("Not yet implemented")
}
override fun deserialize(decoder: Decoder): A {
TODO("Not yet implemented")
}
}ephemient
07/05/2023, 2:21 AMT doesn't seem to be used,
descriptor = B.serializer(NothingSerializer()).descriptor
would probably work in this minimal exampleephemient
07/05/2023, 2:22 AMT, then what you pass in to B.serializer(KSerializer<T>) will have to changeLoney Chou
07/05/2023, 7:45 AMT is used in primary properties. I just omitted them. If so, could you explain a bit more? I kinda don't get your "will have to change".