Why doesn’t kotlin serialization complain about th...
# serialization
p
Why doesn’t kotlin serialization complain about the interface not being serializable here?
Code for those who can’t see images:
Copy code
@Serializable
data class SerializableSomething(
  val i: SomeInterface,
  val b: SomeClass, <- error here
)

interface SomeInterface

class SomeClass
Background: we just had a crash where a sealed interface was not marked as Serializable and relied upon that kotlinx usually fails the compilation if a type is not serializable
a
https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#serializing-interfaces
all interfaces are considered to be implicitly serializable with the PolymorphicSerializer strategy
here’s a relevant bit from the docs, but I’m not sure if it might help!
p
Uh dang. That takes a big portion of the compiler time safety away
I really want to disable that behavior
a
if it was disabled, what serializer would you use for
SomeInterface
?
p
Either the generated serializer if it's marked with Serializable or the one specified in Serializable(with)