FIR: pass the explicit expected type to block type

This helps avoid adding redundant return Unit into block.
This commit is contained in:
Jinseong Jeon
2020-12-08 14:34:25 -08:00
committed by Dmitriy Novozhilov
parent 0ea6b32c01
commit 4ab0897d7d
7 changed files with 23 additions and 19 deletions
@@ -1,6 +1,6 @@
val test1: Function0<Unit>
field = local fun <anonymous>(): Int {
return 42
42 /*~> Unit */
}
get
@@ -5,7 +5,7 @@ FILE fqName:<root> fileName:/coercionToUnit.kt
FUN_EXPR type=kotlin.Function0<kotlin.Int> origin=LAMBDA
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Int
BLOCK_BODY
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Int declared in <root>.test1'
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
CONST Int type=kotlin.Int value=42
FUN DEFAULT_PROPERTY_ACCESSOR name:<get-test1> visibility:public modality:FINAL <> () returnType:kotlin.Function0<kotlin.Unit>
correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val]