-
Notifications
You must be signed in to change notification settings - Fork 217
Description
In general I think our logic for what the valid combinations are was a bit flawed because we used the table for what is allowed in other libraries, but should have used a table based on what is allowed in any library (including the current one). There may be other valid use cases that are not allowed, other than this one, from within the same library.
Use case
You have a sealed class, and you want to ensure all possible implementations of that class are transitive extensions of it.
You can achieve this today by making all the subtypes in your library be themselves base
classes, but it could be easy to miss one on accident, in particular when adding new ones. Allowing sealed base
would allow you to enforce this property, since base
is transitive even within the same library.
Concretely, this is coming up for the Code
class in macros, I want every piece of Code
to ultimately extend the base sealed class, but they must go through some more specific subtype to get there (DeclarationCode
, ExpressionCode
, etc).
It is OK for people to build their own subtypes of those, but only through extension. We want to be able to put in some form of validation in their constructors, and ensure that those constraints are met.