[FE 1.0] Always create return value for CallInstruction
This fixes missing `USED_AS_EXPRESSION` recordings ^KT-47527 Fixed
This commit is contained in:
committed by
TeamCityServer
parent
b2372ff0b9
commit
ae608ea67f
@@ -0,0 +1,47 @@
|
||||
fun test_1(value: Any?): String? {
|
||||
return { // BLOCK
|
||||
val tmp0_safe_receiver: Any? = value
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp0_safe_receiver.let<Any, Nothing>(block = local fun <anonymous>(it: Any): Nothing {
|
||||
return "O"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(value: Any?): String? {
|
||||
return run<Nothing?>(block = local fun <anonymous>(): Nothing? {
|
||||
return { // BLOCK
|
||||
val tmp1_safe_receiver: Any? = value
|
||||
when {
|
||||
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp1_safe_receiver.let<Any, Nothing>(block = local fun <anonymous>(it: Any): Nothing {
|
||||
return "K"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: String = ""
|
||||
result = result.plus(other = { // BLOCK
|
||||
val <elvis>: String? = test_1(value = 1)
|
||||
when {
|
||||
EQEQ(arg0 = <elvis>, arg1 = null) -> return "fail 1"
|
||||
else -> <elvis>
|
||||
}
|
||||
})
|
||||
result = result.plus(other = { // BLOCK
|
||||
val <elvis>: String? = test_2(value = 1)
|
||||
when {
|
||||
EQEQ(arg0 = <elvis>, arg1 = null) -> return "fail 2"
|
||||
else -> <elvis>
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
FILE fqName:<root> fileName:/kt47527.kt
|
||||
FUN name:test_1 visibility:public modality:FINAL <> (value:kotlin.Any?) returnType:kotlin.String?
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_1 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
BLOCK type=kotlin.Nothing? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val]
|
||||
GET_VAR 'value: kotlin.Any? declared in <root>.test_1' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Nothing? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.test_1' type=kotlin.Any? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun let <T, R> (block: kotlin.Function1<T of kotlin.StandardKt.let, R of kotlin.StandardKt.let>): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null
|
||||
<T>: kotlin.Any
|
||||
<R>: kotlin.Nothing
|
||||
$receiver: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.test_1' type=kotlin.Any? origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Any, kotlin.Nothing> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Any) returnType:kotlin.Nothing
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_1 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
CONST String type=kotlin.String value="O"
|
||||
FUN name:test_2 visibility:public modality:FINAL <> (value:kotlin.Any?) returnType:kotlin.String?
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_2 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
CALL 'public final fun run <R> (block: kotlin.Function0<R of kotlin.StandardKt.run>): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Nothing? origin=null
|
||||
<R>: kotlin.Nothing?
|
||||
block: FUN_EXPR type=kotlin.Function0<kotlin.Nothing?> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Nothing? declared in <root>.test_2'
|
||||
BLOCK type=kotlin.Nothing? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Any? [val]
|
||||
GET_VAR 'value: kotlin.Any? declared in <root>.test_2' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Nothing? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_1: kotlin.Any? [val] declared in <root>.test_2.<anonymous>' type=kotlin.Any? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun let <T, R> (block: kotlin.Function1<T of kotlin.StandardKt.let, R of kotlin.StandardKt.let>): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null
|
||||
<T>: kotlin.Any
|
||||
<R>: kotlin.Nothing
|
||||
$receiver: GET_VAR 'val tmp_1: kotlin.Any? [val] declared in <root>.test_2.<anonymous>' type=kotlin.Any? origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Any, kotlin.Nothing> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Any) returnType:kotlin.Nothing
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_2 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
CONST String type=kotlin.String value="K"
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:result type:kotlin.String [var]
|
||||
CONST String type=kotlin.String value=""
|
||||
SET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=null
|
||||
other: BLOCK type=kotlin.String origin=ELVIS
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.String? [val]
|
||||
CALL 'public final fun test_1 (value: kotlin.Any?): kotlin.String? declared in <root>' type=kotlin.String? origin=null
|
||||
value: CONST Int type=kotlin.Int value=1
|
||||
WHEN type=kotlin.String origin=ELVIS
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_2: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="fail 1"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp_2: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
SET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.Unit origin=EQ
|
||||
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=null
|
||||
$this: GET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=null
|
||||
other: BLOCK type=kotlin.String origin=ELVIS
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.String? [val]
|
||||
CALL 'public final fun test_2 (value: kotlin.Any?): kotlin.String? declared in <root>' type=kotlin.String? origin=null
|
||||
value: CONST Int type=kotlin.Int value=1
|
||||
WHEN type=kotlin.String origin=ELVIS
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_3: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="fail 2"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp_3: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
GET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=null
|
||||
@@ -0,0 +1,14 @@
|
||||
// ISSUE: KT-47527
|
||||
// WITH_STDLIB
|
||||
|
||||
fun test_1(value: Any?): String? = value?.let { return "O" }
|
||||
fun test_2(value: Any?): String? = run {
|
||||
value?.let { return "K" }
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
result += test_1(1) ?: return "fail 1"
|
||||
result += test_2(1) ?: return "fail 2"
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
fun test_1(value: Any?): String? {
|
||||
return { // BLOCK
|
||||
val tmp0_safe_receiver: Any? = value
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp0_safe_receiver.let<Any, Nothing>(block = local fun <anonymous>(it: Any): Nothing {
|
||||
return "O"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(value: Any?): String? {
|
||||
return run<Nothing?>(block = local fun <anonymous>(): Nothing? {
|
||||
return { // BLOCK
|
||||
val tmp0_safe_receiver: Any? = value
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_safe_receiver, arg1 = null) -> null
|
||||
else -> tmp0_safe_receiver.let<Any, Nothing>(block = local fun <anonymous>(it: Any): Nothing {
|
||||
return "K"
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: String = ""
|
||||
result = result.plus(other = { // BLOCK
|
||||
val tmp0_elvis_lhs: String? = test_1(value = 1)
|
||||
when {
|
||||
EQEQ(arg0 = tmp0_elvis_lhs, arg1 = null) -> return "fail 1"
|
||||
else -> tmp0_elvis_lhs
|
||||
}
|
||||
})
|
||||
result = result.plus(other = { // BLOCK
|
||||
val tmp1_elvis_lhs: String? = test_2(value = 1)
|
||||
when {
|
||||
EQEQ(arg0 = tmp1_elvis_lhs, arg1 = null) -> return "fail 2"
|
||||
else -> tmp1_elvis_lhs
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
FILE fqName:<root> fileName:/kt47527.kt
|
||||
FUN name:test_1 visibility:public modality:FINAL <> (value:kotlin.Any?) returnType:kotlin.String?
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_1 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
BLOCK type=kotlin.Nothing? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:kotlin.Any? [val]
|
||||
GET_VAR 'value: kotlin.Any? declared in <root>.test_1' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Nothing? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.test_1' type=kotlin.Any? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun let <T, R> (block: kotlin.Function1<T of kotlin.StandardKt.let, R of kotlin.StandardKt.let>): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null
|
||||
<T>: kotlin.Any
|
||||
<R>: kotlin.Nothing
|
||||
$receiver: GET_VAR 'val tmp_0: kotlin.Any? [val] declared in <root>.test_1' type=kotlin.Any? origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Any, kotlin.Nothing> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Any) returnType:kotlin.Nothing
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_1 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
CONST String type=kotlin.String value="O"
|
||||
FUN name:test_2 visibility:public modality:FINAL <> (value:kotlin.Any?) returnType:kotlin.String?
|
||||
VALUE_PARAMETER name:value index:0 type:kotlin.Any?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_2 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
CALL 'public final fun run <R> (block: kotlin.Function0<R of kotlin.StandardKt.run>): R of kotlin.StandardKt.run [inline] declared in kotlin.StandardKt' type=kotlin.Nothing? origin=null
|
||||
<R>: kotlin.Nothing?
|
||||
block: FUN_EXPR type=kotlin.Function0<kotlin.Nothing?> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Nothing?
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Nothing? declared in <root>.test_2'
|
||||
BLOCK type=kotlin.Nothing? origin=SAFE_CALL
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Any? [val]
|
||||
GET_VAR 'value: kotlin.Any? declared in <root>.test_2' type=kotlin.Any? origin=null
|
||||
WHEN type=kotlin.Nothing? origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_1: kotlin.Any? [val] declared in <root>.test_2.<anonymous>' type=kotlin.Any? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: CONST Null type=kotlin.Nothing? value=null
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: CALL 'public final fun let <T, R> (block: kotlin.Function1<T of kotlin.StandardKt.let, R of kotlin.StandardKt.let>): R of kotlin.StandardKt.let [inline] declared in kotlin.StandardKt' type=kotlin.Nothing origin=null
|
||||
<T>: kotlin.Any
|
||||
<R>: kotlin.Nothing
|
||||
$receiver: GET_VAR 'val tmp_1: kotlin.Any? [val] declared in <root>.test_2.<anonymous>' type=kotlin.Any? origin=null
|
||||
block: FUN_EXPR type=kotlin.Function1<kotlin.Any, kotlin.Nothing> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> (it:kotlin.Any) returnType:kotlin.Nothing
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.Any
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test_2 (value: kotlin.Any?): kotlin.String? declared in <root>'
|
||||
CONST String type=kotlin.String value="K"
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
VAR name:result type:kotlin.String [var]
|
||||
CONST String type=kotlin.String value=""
|
||||
SET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUSEQ
|
||||
$this: GET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=PLUSEQ
|
||||
other: BLOCK type=kotlin.String origin=ELVIS
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:kotlin.String? [val]
|
||||
CALL 'public final fun test_1 (value: kotlin.Any?): kotlin.String? declared in <root>' type=kotlin.String? origin=null
|
||||
value: CONST Int type=kotlin.Int value=1
|
||||
WHEN type=kotlin.String origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_2: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="fail 1"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp_2: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
SET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.Unit origin=PLUSEQ
|
||||
CALL 'public final fun plus (other: kotlin.Any?): kotlin.String [operator] declared in kotlin.String' type=kotlin.String origin=PLUSEQ
|
||||
$this: GET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=PLUSEQ
|
||||
other: BLOCK type=kotlin.String origin=ELVIS
|
||||
VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.String? [val]
|
||||
CALL 'public final fun test_2 (value: kotlin.Any?): kotlin.String? declared in <root>' type=kotlin.String? origin=null
|
||||
value: CONST Int type=kotlin.Int value=1
|
||||
WHEN type=kotlin.String origin=null
|
||||
BRANCH
|
||||
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
|
||||
arg0: GET_VAR 'val tmp_3: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
arg1: CONST Null type=kotlin.Nothing? value=null
|
||||
then: RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
CONST String type=kotlin.String value="fail 2"
|
||||
BRANCH
|
||||
if: CONST Boolean type=kotlin.Boolean value=true
|
||||
then: GET_VAR 'val tmp_3: kotlin.String? [val] declared in <root>.box' type=kotlin.String? origin=null
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
GET_VAR 'var result: kotlin.String [var] declared in <root>.box' type=kotlin.String origin=null
|
||||
Reference in New Issue
Block a user