Files
kotlin-fork/compiler/testData/diagnostics/tests/when/nonExhaustiveDependentContext.kt
T
Evgeniy.Zhelenskiy 931f2eab58 [FIR] Remove implicit coercion of ifs and whens to Unit
The rule of thumb is the following:
If the `if` and `when` can be successfully replaced with `while`,
then it is used as a statement, otherwise, it is used as an expression.

#KT-59883
2024-02-21 15:04:03 +00:00

15 lines
289 B
Kotlin
Vendored

// FIR_IDENTICAL
// SKIP_TXT
fun bar(a: String): String {
return when {
a.length == 1 -> {
<!NO_ELSE_IN_WHEN!>when<!> { // Error in K1, no error in K2
a == "a" -> ""
a == "b" -> ""
}
}
else -> ""
}
}