> On Apr 1, 2021, at 9:23 AM, Brian Goetz <brian.go...@oracle.com> wrote:
> 
> ...
> Without trying to paint the bikeshed, this is a pretty simple extension to 
> sealing:
> 
>     sealed interface WithCheese __refines Sandwich { }
> 
> This says that WithCheese is sealed to either classes that extend Sandwich, 
> or other interfaces that __refines Sandwich.  As a bonus, default methods in 
> WithCheese can refer to methods in Sandwich, since it must always be the case 
> that `this instanceof Sandwich`.  
> 
> Essentially, I want to put the `permits` list on Sandwich, and have 
> `WithCheese` and friends delegate their permits to `Sandwich`, rather than 
> having each interface enumerate their subtypes.

Maybe “__refines” should be spelled “extend”?

If an interface J extends a class C, it means that it is a compile-time error 
if class D implements interface J but class D is not a subclass of C.

Such a constraint might be useful even if C is not sealed.

—Guy

Reply via email to