-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sealed interface @Serializable support #1576
Comments
In general, interfaces can not be marked serializable. However sealed interfaces are sort of an exception. However sealed interfaces are a new feature, so I suspect it is not implemented yet in the compiler plugin. |
Then the issue is actual, waiting for implementation 🙃 |
sealed interfaces are currently treated as regular interfaces (can't have serializable annotation and require serializers module). In the future, yes, |
And this feature is tracked here? Is there a roadmap for it? |
Interfaces (regular and sealed) are by default polymorphic. To benefit from sealing (i.e. knowledge of all inheritors in compile-time), @serializable annotation may be added on sealed interface, generating the same serializer that can be used for sealed classes. Synthetic nested classes are not generated in DEFAULT_IMPLS mode because it causes problems when adding a synthetic companion to an interface. Fixes Kotlin/kotlinx.serialization#1576
Is this supported for protobuf too? |
I don't know if it is a bug but just wanted to ask, why can I do
abstract val
stuff with sealed classes but can't do the same thing with interfaces.The text was updated successfully, but these errors were encountered: