Files
kotlin-fork/compiler/testData/diagnostics/tests/when/kt4434.kt
T
2020-03-30 11:15:52 +03:00

36 lines
810 B
Kotlin
Vendored

/*
* RELEVANT SPEC SENTENCES (spec version: 0.1-152, test type: pos):
* - expressions, when-expression -> paragraph 5 -> sentence 1
* - expressions, when-expression, exhaustive-when-expressions -> paragraph 1 -> sentence 1
* - expressions, when-expression, exhaustive-when-expressions -> paragraph 2 -> sentence 1
* - expressions, when-expression -> paragraph 6 -> sentence 5
*/
// KT-4434 Missed diagnostic about else branch in when
package test
fun foo(): Int {
val a = "a"
return if (a.length > 0) {
<!NO_ELSE_IN_WHEN!>when<!> (a) {
"a" -> 1
}
}
else {
3
}
}
fun bar(): Int {
val a = "a"
if (a.length > 0) {
return <!NO_ELSE_IN_WHEN!>when<!> (a) {
"a" -> 1
}
}
else {
return 3
}
}