Is there any way/trick to enforce that classes implementing a specific interface should always be annotated as
@Serializable
?
Copy code
interface ScreenParams
@Serializable
data class CountriesListParams(val listType: CountriesListType) : ScreenParams
@Serializable
data class CountryDetailParams(val countryName: String) : ScreenParams
all these 3 definitions are on different files, so it can happen to forget to set
@Serializable
If the annotation is forgotten, the app would crash at runtime when visiting that specific screen.
s
sandwwraith
05/17/2021, 3:06 PM
Serializable classes implementing an interface should be registered in a polymorphic module. You can't register a class if its not serializable
d
Daniele B
05/17/2021, 5:29 PM
At the moment, I am not registering any polymorphic module and it still seems to decode correctly