I'm trying to serialize a `Box<T>` where `T`...
# serialization
j
I'm trying to serialize a
Box<T>
where
T
is not actually used for serialization purposes and thus does not require a serializer. On JVM and JS this seems to just work, despite
ContextualProvider.Argless
receiving a list of serializers for type parameters on its
invoke
function. On native, however, this fails with an error about not finding a serializer for
T
with
Copy code
On Kotlin/Native explicitly declared serializer should be used for interfaces and enums without @Serializable annotation
I do not control these types and as I said they are not serializable by nature. Is there something I can do to work around this? I started registering serializers that simply throw for the known types that are used inside the library, but that's not really viable as the library user can specify any type as the generic and will receive the same failure.
I solved this by bypassing contextual serialization and special-casing certain types further up the stack such that we emit a direct reference to the serializer rather than allow the library to ever see it