streetsofboston
02/06/2019, 3:35 PMy is declared as Sealed2, which means that any exhaustive when clause need only have branches for V3 and V4.
Of course, x, being of type Sealed1, a when clause needs to check for all values, but could ‘bundle’ all values of Sealed2 by just doing is Sealed2 ->.
If you need to keep them apart, i.e. not pollute the entire Error set of values with new ones that are used just for checkUserIsOldEnough, you must create a entire new set of error-values for that new function, not sub-classing Error.
If All errors must have a common parent-class, make that class an abstract class or interface, not ‘sealed’.