![]() This ability to split declarations will also go for sealed interfaces. The aim is also to allow splitting large sealed class hierarchies into different files to make things more readable. This is also possible for sealed classes and sealed interfaces in Java 15. The Kotlin compiler can still ensure exhaustiveness given that the module is compiled together. This restricts it to only implementations that “you own”. Starting on Kotlin 1.5 location restrictions will get relaxed, so we can declare them on different files under the same module. Kotlin 1.1 made it possible to declare those within the same file. Until not long ago, the compiler was not capable of looking further than the scope of the sealed class itself, so it was forbidden to declare subclasses outside of it. ![]() It needs to know about all the subclasses available in order to ensure exhaustiveness. Limitations on where to write the subclasses of a sealed class are a matter of compiler awareness. You can give feedback on them in YouTrack. ![]() They may be dropped or changed at any time. Short overview of the sealed interfaces coming up in Kotlin 1.5.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |