Files
kotlin-fork/compiler/testData/diagnostics/tests/when/NoElseExpectedUnit.kt
T
Dmitry Petrov 76931affc6 KT-10139:
Non-exhaustive 'when' without 'else' used in expression is an error
regardless of expected type: it can't be an expression, even of type Unit.
2015-12-01 10:36:40 +03:00

7 lines
121 B
Kotlin
Vendored

fun foo(x: Int) {
val y: Unit = <!NO_ELSE_IN_WHEN!>when<!> (x) {
2 -> {}
3 -> {}
}
return y
}