altavir
03/14/2020, 4:37 PMdata class NodeItem<M : Meta>(val node: M) : MetaItem<M>() {
override fun toString(): String = node.toString()
@Serializer(NodeItem::class)
companion object : KSerializer<NodeItem<out Meta>> {
...
}
}
M
is the recursive generics type. It is actually ignored in the serializer since we always use top type.
When I use it, I get class hep.dataforge.meta.MetaBuilder is not registered for polymorphic serialization in the scope of class hep.dataforge.meta.Meta
. Is it possible to somehow bypass polymorphic serializers and actually use interface type for serialization?altavir
03/15/2020, 6:18 AM@Serializable(MetaSerializer::class) val node: M
. I guess it could cause classcast errors, but will hold for now.