[K/N][IR] Generate missing return when using Nothing-returning safe call as lambda result or function expression body

^KT-42832
This commit is contained in:
Dmitriy Dolovov
2021-04-12 15:11:01 +03:00
parent b4813d31e6
commit 5e392a511f
4 changed files with 58 additions and 1 deletions
@@ -0,0 +1,18 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package codegen.function.nothingN_returning_safe_call1
import kotlin.test.*
fun Any.nothing(): Nothing {
while (true) {}
}
fun foo(obj: Any?): Nothing? = obj?.nothing()
fun main() {
foo(null)
}
@@ -0,0 +1,23 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package codegen.function.nothingN_returning_safe_call2
import kotlin.test.*
fun Any.nothing(): Nothing {
while (true) {}
}
fun foo() {
val block: (Any?) -> Nothing? = {
it?.nothing()
}
block(null)
}
fun main() {
foo()
}