andylamax
03/18/2022, 8:24 AM@Serializable
sealed class InfoResults<out T> {
@Serializable
data class Shared<out T>(val data: T) : InfoResults<T>()
@Serializable
data class NotShared(val message: String) : InfoResults<Nothing>()
}rtsketo
03/18/2022, 9:02 AMrtsketo
03/18/2022, 9:09 AMandylamax
03/18/2022, 9:19 AMShouldn't there be properties to serialize?No. It is not a must for there to be properties for it to be serializable.
andylamax
03/18/2022, 9:20 AMAs it is, InfoResults doesn't have to be Serializable. It doesn't contain any properties to serialize.If
InfoResults is not marked as serializable, I can't successfully call Json.encodeToString<InfoResults<String>>(ir)andylamax
03/18/2022, 9:21 AMNotShared casePetter Måhlén
03/18/2022, 9:50 AMNothing .rocketraman
03/18/2022, 1:49 PMNothing type parameter on one of its subclasses, and it serializes without problem.
I think the difference may be that my equivalent of NotShared is an object.andylamax
03/18/2022, 10:18 PMrocketraman
03/18/2022, 10:18 PMandylamax
03/18/2022, 10:19 PMandylamax
03/18/2022, 11:12 PMrocketraman
03/18/2022, 11:16 PMandylamax
03/18/2022, 11:31 PM