[NI] Take into account return without expression in lambdas

This commit is contained in:
Dmitry Petrov
2017-06-09 15:06:42 +03:00
committed by Mikhail Zarechenskiy
parent 17cdbcca03
commit 4963580f90
7 changed files with 65 additions and 20 deletions
+10
View File
@@ -18,6 +18,16 @@ fun test2() {
}
}
// TODO we don't see 'return@lambda' inside internal lambda when we analyze an external lambda,
// so type information from NI is actually incorrect, see KT-18392
fun test3() {
run lambda@{
run {
return@lambda
}
}
}
fun testLrmFoo1(ints: List<Int>) {
ints.forEach lit@ {
if (it == 0) return@lit
+18
View File
@@ -29,6 +29,24 @@ FILE /nonLocalReturn.kt
RETURN type=kotlin.Nothing from='<anonymous>(): Unit'
GET_OBJECT 'Unit' type=kotlin.Unit
FUNCTION_REFERENCE '<anonymous>(): Unit' type=() -> kotlin.Unit origin=LAMBDA
FUN public fun test3(): kotlin.Unit
BLOCK_BODY
CALL 'run(() -> Nothing): Nothing' type=kotlin.Nothing origin=null
<R>: Nothing
block: BLOCK type=() -> kotlin.Nothing origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA local final fun <anonymous>(): kotlin.Nothing
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(): Nothing'
CALL 'run(() -> Nothing): Nothing' type=kotlin.Nothing origin=null
<R>: Nothing
block: BLOCK type=() -> kotlin.Nothing origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA local final fun <anonymous>(): kotlin.Nothing
BLOCK_BODY
RETURN type=kotlin.Nothing from='<anonymous>(): Nothing'
TYPE_OP type=kotlin.Nothing origin=IMPLICIT_CAST typeOperand=kotlin.Nothing
GET_OBJECT 'Unit' type=kotlin.Unit
FUNCTION_REFERENCE '<anonymous>(): Nothing' type=() -> kotlin.Nothing origin=LAMBDA
FUNCTION_REFERENCE '<anonymous>(): Nothing' type=() -> kotlin.Nothing origin=LAMBDA
FUN public fun testLrmFoo1(ints: kotlin.collections.List<kotlin.Int>): kotlin.Unit
VALUE_PARAMETER value-parameter ints: kotlin.collections.List<kotlin.Int>
BLOCK_BODY