[FE 1.0] Fix reporting of non exhaustive when statement for whens with subject

^KT-48653 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-09-09 15:19:18 +03:00
parent f6ae6af741
commit 7a7672b0de
9 changed files with 145 additions and 4 deletions
@@ -0,0 +1,22 @@
// FIR_IDENTICAL
// LANGUAGE: -ProhibitNonExhaustiveWhenOnAlgebraicTypes
// ISSUE: KT-48653
sealed class Sealed {
object A : Sealed()
object B : Sealed()
}
fun functionReturningSealed(): Sealed = null!!
fun test_1() {
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (val result = functionReturningSealed()) {
is Sealed.A -> {}
}
}
fun test_2() {
val result2 = functionReturningSealed()
<!NON_EXHAUSTIVE_WHEN_STATEMENT!>when<!> (result2) {
is Sealed.A -> {}
}
}