Add some data flow analysis tests on when
This commit is contained in:
committed by
Dmitry Petrov
parent
ae929d0f08
commit
148d03e365
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: +VariableDeclarationInWhenSubject
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
enum class E { FIRST, SECOND }
|
||||
|
||||
fun testSmartcastToEnumInSubjectInitializer(e: E?) {
|
||||
val x = <!NO_ELSE_IN_WHEN!>when<!> (val ne = e!!) { // TODO fix
|
||||
E.FIRST -> "f"
|
||||
E.SECOND -> "s"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
sealed class Either
|
||||
class Left : Either()
|
||||
class Right : Either()
|
||||
|
||||
fun testSmartcastToSealedInSubjectInitializer(x: Any?) {
|
||||
val y = <!NO_ELSE_IN_WHEN!>when<!> (val either = x as Either) { // TODO fix
|
||||
is Left -> "L"
|
||||
is Right -> "R"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user