FIR: Fix incorrect type of block generated for inc operator

Previously, it was obtained from expected type of a variable being assigned,
but it's better to use the type of resulting expression

Initially this part was brought in 4ab0897d7d,
but as we see in commit message and tests it was all about unit-coercion
This commit is contained in:
Denis.Zharkov
2021-11-11 12:55:40 +03:00
committed by teamcityserver
parent a7859e0332
commit c0b6a593e0
17 changed files with 67 additions and 20 deletions
@@ -2,8 +2,8 @@ FILE fqName:<root> fileName:/coercionToUnit.kt
PROPERTY name:test1 visibility:public modality:FINAL [val]
FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Function0<kotlin.Unit> visibility:private [final,static]
EXPRESSION_BODY
FUN_EXPR type=kotlin.Function0<kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CONST Int type=kotlin.Int value=42
@@ -1,5 +1,5 @@
val test1: Function0<Unit>
field = local fun <anonymous>(): Int {
field = local fun <anonymous>() {
42 /*~> Unit */
}
@@ -11,5 +11,4 @@ FILE fqName:<root> fileName:/lambdaReturningUnit.kt
block: FUN_EXPR type=kotlin.Function0<kotlin.Any?> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Any?
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Any? declared in <root>.box'
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
@@ -4,7 +4,7 @@ inline fun flaf(block: Function0<Any?>) {
suspend fun box() {
flaf(block = local fun <anonymous>(): Any? {
return Unit
Unit
}
)
}