23 lines
397 B
Kotlin
Vendored
23 lines
397 B
Kotlin
Vendored
sealed class Stmt
|
|
|
|
class ForStmt : Stmt()
|
|
|
|
sealed class Expr : Stmt() {
|
|
object BinExpr : Expr()
|
|
}
|
|
|
|
fun test(x: Stmt): String =
|
|
when (x) {
|
|
is Expr -> "expr"
|
|
is Stmt -> "stmt"
|
|
}
|
|
|
|
fun test2(x: Stmt): String =
|
|
when (x) {
|
|
is Expr -> "expr"
|
|
}
|
|
|
|
fun test3(x: Expr): String =
|
|
when (x) {
|
|
is Stmt -> "stmt"
|
|
} |