It is possible to have sealed interfaces?

#1

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
#2

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
#3

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?

#4

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