[FIR] Implement checker for exhaustive when's in expression position

This commit is contained in:
Dmitriy Novozhilov
2021-02-04 15:41:57 +03:00
parent 3f715e671d
commit 8dd9d98129
103 changed files with 919 additions and 617 deletions
@@ -10,7 +10,7 @@ object CC : C()
fun foo(a: A) {
if (a is B) {
if (a is C) {
val t = when (a) {
val t = <!NO_ELSE_IN_WHEN!>when<!> (a) {
is CC -> "CC"
}
}
@@ -20,9 +20,9 @@ fun foo(a: A) {
fun foo2(a: A) {
if (a is C) {
if (a is B) {
val t = when (a) {
val t = <!NO_ELSE_IN_WHEN!>when<!> (a) {
is CC -> "CC"
}
}
}
}
}
@@ -0,0 +1,9 @@
public fun foo(x: String?, y: String?): Int {
while (true) {
x ?: <!INVALID_IF_AS_EXPRESSION!>if<!> (y == null) break
// y is nullable if x != null
y<!UNSAFE_CALL!>.<!>length
}
// y is null because of the break
return y<!UNSAFE_CALL!>.<!>length
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
public fun foo(x: String?, y: String?): Int {
while (true) {
x ?: if (y == null) break
@@ -7,4 +6,4 @@ public fun foo(x: String?, y: String?): Int {
}
// y is null because of the break
return y<!UNSAFE_CALL!>.<!>length
}
}