Files
kotlin-fork/compiler/testData/diagnostics/tests/controlFlowAnalysis/throwInLambda.fir.kt
T
Pavel Kirpichenkov a9391c8dfb [NI] Remove Nothing result type restriction in most cases
Make Nothing as result type not suitable only for if, when, try and ?: special functions.
2019-12-25 14:59:05 +03:00

12 lines
293 B
Kotlin
Vendored

// See KT-10913 Bogus unreachable code warning
fun fn() : String? = null
fun foo(): String {
val x = fn()?.let { throw Exception() } ?: "unreachable?"
return x
}
fun bar(): String {
val x = fn() ?: return ""
val y = x?.let { throw Exception() } ?: "unreachable"
return y
}