Are there ways to push the checks towards compile-...
# serialization
r
Are there ways to push the checks towards compile-time? I sometimes have an
Any
that's trying to get serialized, and I only realize that once I run the code.
e
example? there is no
Any.serializer()
so normally it's quite difficult to get
Any
into a
@Serializable
structure, failing at compile time…
u
I lowkey think having the type-inferred overload was a mistake; I too was burned & especiially when serializing sealed class concrete types
json.encodeToString(Child(..))
like more than twice
r
serialize(if (X) { Y } else { Z }
if
Y)
and
Z
disagree on type, it's reasonably easy to get there
e
never had in any codebase I work on blob shrug even if that worked, that wouldn't lead to output that can be deserialized
r
It fails at runtime, I want it to fail at compile time.
u
well it's part of public API so you're SOL. Just a lint rule maybe