diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java index 1b531d6a842..a587e8d7485 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirBlackBoxCodegenBasedTestGenerated.java @@ -51475,6 +51475,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java index c7bef73ed42..6542a0f80f8 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirReversedBlackBoxCodegenBasedTestGenerated.java @@ -51475,6 +51475,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt index b30c1a32359..559a0b6e512 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/AdapterGenerator.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.fir.resolve.calls.FirFakeArgumentForCallableReferenc import org.jetbrains.kotlin.fir.resolve.calls.ResolvedCallArgument import org.jetbrains.kotlin.fir.resolve.substitution.AbstractConeSubstitutor import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol -import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol @@ -411,10 +410,9 @@ internal class AdapterGenerator( } } - val unwrappedArgument = argument.unwrapArgument() - if (unwrappedArgument !is FirSamConversionExpression) return this + if (argument !is FirSamConversionExpression) return this - val samFirType = unwrappedArgument.resolvedType.let { it.removeExternalProjections() ?: it } + val samFirType = argument.resolvedType.let { it.removeExternalProjections() ?: it } val samType = samFirType.toIrType(ConversionTypeOrigin.DEFAULT) // Make sure the converted IrType owner indeed has a single abstract method, since FunctionReferenceLowering relies on it. @@ -429,12 +427,12 @@ internal class AdapterGenerator( // BLOCK ADAPTED_FUNCTION_REFERENCE(FUN ADAPTER_FOR_CALLABLE_REFERENCE, TYPE_OP SAM_CONVERSION(FUNCTION_REFERENCE)) // Therefore, we need to insert the cast as the last statement of the block, not around the block itself. val lastIndex = statements.lastIndex - val samConversion = (statements[lastIndex] as IrExpression).generateSamConversion(samType, unwrappedArgument, samFirType) + val samConversion = (statements[lastIndex] as IrExpression).generateSamConversion(samType, argument, samFirType) statements[lastIndex] = samConversion this.type = samConversion.type this } else { - generateSamConversion(samType, unwrappedArgument, samFirType) + generateSamConversion(samType, argument, samFirType) } } diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt index d9ffc518979..acc85f46bd9 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/CallAndReferenceGenerator.kt @@ -1064,11 +1064,12 @@ class CallAndReferenceGenerator( // In this case we have to use parameter type itself which is more precise, like Array or IntArray. // See KT-62598 and its fix for details. val expectedType = unsubstitutedParameterType.takeIf { visitor.annotationMode && unsubstitutedParameterType?.isArrayType == true } - var irArgument = visitor.convertToIrExpression(argument, expectedType = expectedType) + val unwrappedArgument = argument.unwrapArgument() + var irArgument = visitor.convertToIrExpression(unwrappedArgument, expectedType = expectedType) if (unsubstitutedParameterType != null) { with(visitor.implicitCastInserter) { - val argumentType = argument.resolvedType.fullyExpandedType(session) - if (argument is FirSmartCastExpression) { + val argumentType = unwrappedArgument.resolvedType.fullyExpandedType(session) + if (unwrappedArgument is FirSmartCastExpression) { val substitutedParameterType = substitutor.substituteOrSelf(unsubstitutedParameterType) // here we should use a substituted parameter type to properly choose the component of an intersection type // to provide a proper cast to the smartcasted type @@ -1076,7 +1077,7 @@ class CallAndReferenceGenerator( } // here we should pass unsubstituted parameter type to properly infer if the original type accepts null or not // to properly insert nullability check - irArgument = irArgument.insertSpecialCast(argument, argumentType, unsubstitutedParameterType) + irArgument = irArgument.insertSpecialCast(unwrappedArgument, argumentType, unsubstitutedParameterType) } } with(adapterGenerator) { @@ -1085,13 +1086,13 @@ class CallAndReferenceGenerator( val parameterType = parameter.returnTypeRef.coneType val unwrappedParameterType = if (parameter.isVararg) parameterType.arrayElementType()!! else parameterType val samFunctionType = getFunctionTypeForPossibleSamType(unwrappedParameterType) - irArgument = irArgument.applySuspendConversionIfNeeded(argument, samFunctionType ?: unwrappedParameterType) - irArgument = irArgument.applySamConversionIfNeeded(argument, parameter) + irArgument = irArgument.applySuspendConversionIfNeeded(unwrappedArgument, samFunctionType ?: unwrappedParameterType) + irArgument = irArgument.applySamConversionIfNeeded(unwrappedArgument, parameter) } } return irArgument - .applyAssigningArrayElementsToVarargInNamedForm(argument, parameter) - .applyImplicitIntegerCoercionIfNeeded(argument, parameter) + .applyAssigningArrayElementsToVarargInNamedForm(unwrappedArgument, parameter) + .applyImplicitIntegerCoercionIfNeeded(unwrappedArgument, parameter) } private fun IrExpression.applyAssigningArrayElementsToVarargInNamedForm( diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index 9c7ca184dff..d7e07359ced 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -51200,6 +51200,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java index aea04687568..a79bfdad544 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.java @@ -51200,6 +51200,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 751fcd7ffcb..f7f5e931dae 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -51200,6 +51200,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt new file mode 100644 index 00000000000..6524e08be07 --- /dev/null +++ b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.fir.ir.txt @@ -0,0 +1,53 @@ +FILE fqName: fileName:/suspendSamConstructorAdaptation.kt + CLASS INTERFACE name:FunInterface modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FunInterface + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:invoke visibility:public modality:ABSTRACT <> ($this:.FunInterface) returnType:kotlin.Unit [suspend,operator] + $this: VALUE_PARAMETER name: type:.FunInterface + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:lambda type:kotlin.Function0 [val] + FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + 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 + CALL 'public final fun func (f: .FunInterface): kotlin.Unit declared in ' type=kotlin.Unit origin=null + f: BLOCK type=.FunInterface origin=SUSPEND_CONVERSION + FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion visibility:local modality:FINAL <> ($receiver:kotlin.Function0) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0 + BLOCK_BODY + CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=kotlin.Unit origin=null + $this: GET_VAR 'callee: kotlin.Function0 declared in .box.suspendConversion' type=kotlin.Function0 origin=null + 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: BLOCK type=.FunInterface origin=SUSPEND_CONVERSION + FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion visibility:local modality:FINAL <> ($receiver:kotlin.Function0) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0 + BLOCK_BODY + CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=kotlin.Unit origin=null + $this: GET_VAR 'callee: kotlin.Function0 declared in .box.suspendConversion' type=kotlin.Function0 origin=null + 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 + 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 + VALUE_PARAMETER name:f index:0 type:.FunInterface + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun func (f: .FunInterface): kotlin.Unit declared in ' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit diff --git a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt new file mode 100644 index 00000000000..9a944ef2b16 --- /dev/null +++ b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.ir.txt @@ -0,0 +1,53 @@ +FILE fqName: fileName:/suspendSamConstructorAdaptation.kt + CLASS INTERFACE name:FunInterface modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.FunInterface + FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] + overridden: + public open fun equals (other: kotlin.Any?): kotlin.Boolean declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:invoke visibility:public modality:ABSTRACT <> ($this:.FunInterface) returnType:kotlin.Unit [suspend,operator] + $this: VALUE_PARAMETER name: type:.FunInterface + FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String + BLOCK_BODY + VAR name:lambda type:kotlin.Function0 [val] + FUN_EXPR type=kotlin.Function0 origin=LAMBDA + FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> () returnType:kotlin.Unit + 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 + CALL 'public final fun func (f: .FunInterface): kotlin.Unit declared in ' type=kotlin.Unit origin=null + f: BLOCK type=.FunInterface origin=SUSPEND_CONVERSION + FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion0 visibility:local modality:FINAL <> ($receiver:kotlin.Function0) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0 + BLOCK_BODY + CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=kotlin.Unit origin=null + $this: GET_VAR 'callee: kotlin.Function0 declared in .box.suspendConversion0' type=kotlin.Function0 origin=null + TYPE_OP type=.FunInterface origin=SAM_CONVERSION typeOperand=.FunInterface + FUNCTION_REFERENCE 'local final fun suspendConversion0 (): 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: BLOCK type=.FunInterface origin=SUSPEND_CONVERSION + FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion1 visibility:local modality:FINAL <> ($receiver:kotlin.Function0) returnType:kotlin.Unit [suspend] + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0 + BLOCK_BODY + CALL 'public abstract fun invoke (): R of kotlin.Function0 declared in kotlin.Function0' type=kotlin.Unit origin=null + $this: GET_VAR 'callee: kotlin.Function0 declared in .box.suspendConversion1' type=kotlin.Function0 origin=null + 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 + 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 + VALUE_PARAMETER name:f index:0 type:.FunInterface + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun func (f: .FunInterface): kotlin.Unit declared in ' + GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit diff --git a/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt new file mode 100644 index 00000000000..81454a8f1a7 --- /dev/null +++ b/compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt @@ -0,0 +1,16 @@ +// DUMP_IR +// IGNORE_BACKEND_K1: JVM +// ^K1 with old backend reports FUN_INTERFACE_WITH_SUSPEND_FUNCTION + +fun interface FunInterface { + suspend operator fun invoke() +} + +fun func(f: FunInterface) = Unit + +fun box(): String { + val lambda: () -> Unit = { } + func(f = lambda) + func(lambda) + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java index c5b6bbc800a..d8f4bbb913c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/JvmAbiConsistencyTestBoxGenerated.java @@ -50510,6 +50510,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 17407e70868..08086ef6a9b 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -47414,6 +47414,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index 891464a52eb..34813fa35b0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -50510,6 +50510,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 4ac01b6f53b..77874297918 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -50510,6 +50510,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @Test @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 9ba141725cd..328437598bf 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -40574,6 +40574,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } + @TestMetadata("syntheticVsReal.kt") public void testSyntheticVsReal() { runTest("compiler/testData/codegen/box/sam/constructors/syntheticVsReal.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index dfd23acb21d..7ea3ea13952 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -35395,6 +35395,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java index d1daba96809..b00f58b47fd 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsES6CodegenBoxTestGenerated.java @@ -35395,6 +35395,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index 9b1be8cfb3c..ac9fb71a579 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -34831,6 +34831,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index cd9257c6dd3..f56383579ad 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -34831,6 +34831,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java index b0425975539..0b07373499d 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestGenerated.java @@ -38781,6 +38781,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java index f98cd5ac754..8a594085f95 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/FirNativeCodegenBoxTestNoPLGenerated.java @@ -39767,6 +39767,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java index fb3d098ada0..0bfd63be2af 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestGenerated.java @@ -37219,6 +37219,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java index 5b441a6d60a..c3c1bb8328b 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/test/blackbox/NativeCodegenBoxTestNoPLGenerated.java @@ -38194,6 +38194,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmJsCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmJsCodegenBoxTestGenerated.java index fdd5bf50260..d988b0b61a1 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmJsCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/FirWasmJsCodegenBoxTestGenerated.java @@ -35269,6 +35269,12 @@ public class FirWasmJsCodegenBoxTestGenerated extends AbstractFirWasmJsCodegenBo public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java index ced66a5a380..592859b1daa 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/K1WasmCodegenBoxTestGenerated.java @@ -34705,6 +34705,12 @@ public class K1WasmCodegenBoxTestGenerated extends AbstractK1WasmCodegenBoxTest public void testSameWrapperClass2() { runTest("compiler/testData/codegen/box/sam/constructors/sameWrapperClass2.kt"); } + + @Test + @TestMetadata("suspendSamConstructorAdaptation.kt") + public void testSuspendSamConstructorAdaptation() { + runTest("compiler/testData/codegen/box/sam/constructors/suspendSamConstructorAdaptation.kt"); + } } @Nested