-
-
Notifications
You must be signed in to change notification settings - Fork 934
Description
Feature request
Introduce support for sealed classes & interfaces. A sealed class-like is such that it's children (extends and implementations) can only be defined under the same namespace it is. A sealed class must be declared abstract because such classes are guaranteed to be extended and, therefore, shouldn't be an implementation themselves.
Reference: https://kotlinlang.org/docs/sealed-classes.html
This is very similar to a draft "Tagged Enums" PHP RFC, except with support for interfaces and spanning implementations accross the whole namespace, instead of just one file: https://wiki.php.net/rfc/tagged_unions
The feature should be pretty easy to implement: one annotation, one reflection method isSealed() and a rule that makes sure extended class/implemented interface is either not sealed or is under the same namespace as the @sealed marked class/interface.
Further improvements, such as exhaustive switch/match checks, could be implemented down the line.