From 1a5fa8d3f6e21cfb6843f81ebd0577732c622cef Mon Sep 17 00:00:00 2001 From: Kirill Rakhman Date: Fri, 1 Mar 2024 15:35:02 +0100 Subject: [PATCH] [Tests] Add test for suspend SAM conversion with trailing lambda #KT-65878 #KT-66124 --- .../suspendSamConstructorAdaptation.fir.ir.txt | 7 +++++++ .../constructors/suspendSamConstructorAdaptation.ir.txt | 7 +++++++ .../sam/constructors/suspendSamConstructorAdaptation.kt | 1 + 3 files changed, 15 insertions(+) diff --git a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt index 6524e08be07..b6e29ce976f 100644 --- a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt +++ b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt @@ -44,6 +44,13 @@ FILE fqName: fileName:/suspendSamConstructorAdaptation.kt TYPE_OP type=.FunInterface origin=SAM_CONVERSION typeOperand=.FunInterface FUNCTION_REFERENCE 'local final fun suspendConversion (): kotlin.Unit declared in .box' type=kotlin.coroutines.SuspendFunction0 origin=SUSPEND_CONVERSION reflectionTarget=null $receiver: GET_VAR 'val lambda: kotlin.Function0 declared in .box' type=kotlin.Function0 origin=null + CALL 'public final fun func (f: .FunInterface): kotlin.Unit declared in ' type=kotlin.Unit origin=null + f: TYPE_OP type=.FunInterface origin=SAM_CONVERSION typeOperand=.FunInterface + FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .box' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="OK" FUN name:func visibility:public modality:FINAL <> (f:.FunInterface) returnType:kotlin.Unit diff --git a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt index 9a944ef2b16..1fc1d23904d 100644 --- a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt +++ b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt @@ -44,6 +44,13 @@ FILE fqName: fileName:/suspendSamConstructorAdaptation.kt TYPE_OP type=.FunInterface origin=SAM_CONVERSION typeOperand=.FunInterface FUNCTION_REFERENCE 'local final fun suspendConversion1 (): kotlin.Unit declared in .box' type=kotlin.coroutines.SuspendFunction0 origin=SUSPEND_CONVERSION reflectionTarget=null $receiver: GET_VAR 'val lambda: kotlin.Function0 declared in .box' type=kotlin.Function0 origin=null + CALL 'public final fun func (f: .FunInterface): kotlin.Unit declared in ' type=kotlin.Unit origin=null + f: TYPE_OP type=.FunInterface origin=SAM_CONVERSION typeOperand=.FunInterface + FUN_EXPR type=kotlin.coroutines.SuspendFunction0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit [suspend] + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .box' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in ' CONST String type=kotlin.String value="OK" FUN name:func visibility:public modality:FINAL <> (f:.FunInterface) returnType:kotlin.Unit diff --git a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt index 81454a8f1a7..2c500981e05 100644 --- a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt +++ b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt @@ -12,5 +12,6 @@ fun box(): String { val lambda: () -> Unit = { } func(f = lambda) func(lambda) + func {} return "OK" } \ No newline at end of file