Hello, how could I solve this generic parameter is...
# serialization
l
Hello, how could I solve this generic parameter issue?
Copy code
@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")
    }
}
e
since
T
doesn't seem to be used,
Copy code
descriptor = B.serializer(NothingSerializer()).descriptor
would probably work in this minimal example
if you really use
T
, then what you pass in to
B.serializer(KSerializer<T>)
will have to change
l
Thank you,
T
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".