It is possible to have sealed interfaces?


Hi, as a developer I think that will be helpful to have in the language the concept of sealed interfaces.
It is something that you think can be added in the future?

1 Like

Two years ago, @yole wrote the following on a reddit post about the same topic:

Kotlin does not support sealed interfaces because there is no way to prevent Java classes from implementing the same interface. Therefore, it’s not possible to obtain the exhaustiveness guarantee that sealed classes provide.

1 Like

Thank you for the answer, so I guess that it could be possible in a Kotlin-only environment like Kotlin native for example, or am I wrong?


There were some discussions about it in some places. The sealed interfaces will be probably added to the language (either with safety feature like name mangling or with opt-in key which will allow to bypass some Java-safety) in the future, but it is not a first priority.

1 Like