Question about JEP 406

Jim Laskey james.laskey at oracle.com
Tue Jun 15 16:59:39 UTC 2021


[HTML messed up in original code]

sealed interface Exp<T> {
  record Add(Exp<Integer> lhs, Exp<Integer> rhs) implements Exp<Integer> {}
  record Lit<T>(T obj) implements Exp<T> {}
}​


> On May 21, 2021, at 2:06 AM, Tesla Ice Zhang <ice1000kotlin at foxmail.com> wrote:
> 
> Hi OpenJDK developers,
> 
> I'm very excited about JEP 406. Sealed classes are taken into account in switch expressions, which is great! However, there is one special case not mentioned in the JEP, about generic sealed interfaces:
> 
> 
> sealed interface Exp<T> {
>  record Add(Exp<Integer> lhs, Exp<Integer> rhs) implements Exp<Integer> {}
>  record Lit<T>(T obj) implements Exp<T> {}
> }​
> 
> 
> 
> In the above example, if we do a switch on an expression of type Exp<Boolean>, do we need to provide a case for Add?
> 
> 
> Best regards,
> Tesla



More information about the amber-dev mailing list