[FIR] Implement checker for exhaustive when's in expression position
This commit is contained in:
+3
-3
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -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
-2
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user