efemoney
07/30/2020, 11:14 PMinterface Field<Value> {...}
interface InputField<InputT> : Field<InputT> {...}
interface SelectorField<ValueT> : Field<ValueT> {...}
abstract class NumberField : InputField<Number> {...}
abstract class BooleanField : SelectorField<Boolean> {...}
@Serializable
data class NumberFieldImpl(...): NumberField()
@Serializable
data class BooleanFieldImpl(...): BooleanField()
Also I have a custom _map_:
// Need to add serializable on base class else compiler complains
@Serializable
abstract class MapBackedContainer<K, V>(val storage: MutableMap<K, V>) : MutableMap<K, V> by storage
@Serializable // Currently fails compile, message below
class FieldContainer : MapBackedContainer<String, Field<*>>
@Serializable // This one has no errors, ActionImpl is non generic and annotated with @Serializable
class ActionContainer : MapBackedContainer<String, ActionImpl>
FieldContainer
currently fails compile with the message “Serializer for element of type Any? has not been found. To use context serializer as fallback, explicitly annotate element with @Contextual”.
I tried adding @Serializable
on the intermediate abstract classes of Field<*>
but the issue is the same. Same with adding @Contextual
on the Field<*> generic parameter of FieldContainer.Dominaezzz
07/30/2020, 11:30 PMDominaezzz
07/30/2020, 11:30 PMField<*>
hasn't been marked as @Serializable
too.efemoney
07/30/2020, 11:43 PMDominaezzz
07/30/2020, 11:50 PM*
is not serializable. That's what is refered to as Any?
sandwwraith
07/31/2020, 11:06 AMField<Value>
does not specify upper bound, Field<*>
is a Field<Any?>
for serialization framework. You may try Field<@Polymorphic Any>
instead.efemoney
07/31/2020, 11:26 AMsandwwraith
07/31/2020, 11:34 AMefemoney
07/31/2020, 11:47 AMCountry
is Serializable.sandwwraith
07/31/2020, 11:50 AMoverride var name: String = id.capitalize(Locale.ROOT)
to override val name: String get() = ...
. It's an old bug (https://github.com/Kotlin/kotlinx.serialization/issues/133) 😞efemoney
07/31/2020, 11:50 AMefemoney
07/31/2020, 11:50 AMefemoney
07/31/2020, 11:54 AM