Most of the time ChatId is serialized successfully, and the descriptor field of ChatIdSerializer is not used.
But I was trying editMessageReplyMarkup method and ChatId there is optional. \
Therefore, it stumbled upon the following line in kotlinx.serialization: kotlinx/serialization/encoding/Encoding.kt#L291 and there was stack overflow error trying to get the descriptor:
at com.elbekd.bot.model.internal.ChatIdSerializer.getDescriptor(serializers.kt:13)
at com.elbekd.bot.model.internal.ChatIdSerializer.getDescriptor(serializers.kt:13)
There is Content-based polymorphic deserialization in kotlinx.serialization that could be used here, but this would lead to more boilerplate code (because it would require ChatId.StringId and ChatId.IntegerId to be serializable and a custom serializer class for each). So I just copied the descriptor implementation from JsonContentPolymorphicSerializer class here and it works now.
Most of the time
ChatId
is serialized successfully, and thedescriptor
field ofChatIdSerializer
is not used.But I was trying
editMessageReplyMarkup
method andChatId
there is optional. \ Therefore, it stumbled upon the following line inkotlinx.serialization
: kotlinx/serialization/encoding/Encoding.kt#L291 and there was stack overflow error trying to get the descriptor:There is Content-based polymorphic deserialization in
kotlinx.serialization
that could be used here, but this would lead to more boilerplate code (because it would requireChatId.StringId
andChatId.IntegerId
to be serializable and a custom serializer class for each). So I just copied the descriptor implementation fromJsonContentPolymorphicSerializer
class here and it works now.