Question about JEP 406

Tesla Ice Zhang ice1000kotlin at foxmail.com
Fri May 21 05:06:37 UTC 2021


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