Open httpdispatch opened 11 months ago
The problem is in getContextualDescriptor
function (https://github.com/Kotlin/kotlinx.serialization/blob/45976024789fce101b650f3fe5546dd30362658a/core/commonMain/src/kotlinx/serialization/descriptors/ContextAware.kt#L60) that doesn't pass required parameters to module.getContextual
. It looks like the ContextAware
descriptor should store type parameters serializers, too.
@sandwwraith are there any workarounds till it is fixed? The only one I've found is too use json.serializersModule.serializer()
method, but it requires json reference.
@httpdispatch If you know concrete type of Box
type argument in advance you can replace args -> BoxSerializer(args[0])
with e.g. BoxSerializer(String.serializer())
@sandwwraith unfortunately I don't know generic type in advance. Also my real contextual serializer has additional dependencies so can't create it on demand in any place. That is why I tried to use ContextualSerializer which fits well in similar cases.
Describe the bug When i try to encode generic data to the JSON element using
ContextualSerializer
, the following crash occursTo Reproduce
Expected behavior
Serialization should be performed properly without crash. Deserialization works as expected
Environment