Refinements for sealed types

Alex Buckley alex.buckley at
Mon Aug 19 17:26:32 UTC 2019

On 8/18/2019 12:25 PM, Brian Goetz wrote:
> So, given all this, we should focus all our ceremony-reduction on the 
> case of co-declared sum types.  Which is mostly what I think I was 
> suggesting:
>   - Infer the permits clause when all the subtypes are co-declared;
>   - Infer “final” for leaf classes in a sum type;
>   - Require explicitness in both sealed/non-sealed, and permits clause, 
> in other cases.

How do you know from `sealed class X {}` and the rest of its compilation 
unit that all X's subtypes are co-declared? Maybe there's another class 
which extends X that someone forgot to pass to javac. Do you really mean 
to determine which subfeature is in use (and hence whether ceremony 
reduction is needed) based on what the host system can observe? I 
wondered if your intention is for a top-level sealed RECORD class to 
indicate sum-types code and a top-level sealed ABSTRACT class to 
indicate restricted-hierarchy code, but you downplayed 
abstract-superclass for restricted hierarchies earlier.


More information about the amber-spec-experts mailing list