sealed interface Expr permits MathExpr, NotANumber { .. } sealed class MathExpr() implements Expr { .. } final class NotANumber implements Expr { .. }