Files
kotlin-fork/compiler/testData/diagnostics/tests/sealed/ExhaustiveOnRoot.kt
T
Dmitry Neverov cd24adac32 Detect redundant 'is' check
#KT-14187 Fixed
2017-05-15 11:24:35 +03:00

23 lines
465 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"
<!USELESS_IS_CHECK!>is Stmt<!> -> "stmt"
}
fun test2(x: Stmt): String =
<!NO_ELSE_IN_WHEN!>when<!> (x) {
is Expr -> "expr"
}
fun test3(x: Expr): String =
when (x) {
<!USELESS_IS_CHECK!>is Stmt<!> -> "stmt"
}