diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index 00b94f78b05..0b906f17fcd 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -4934,6 +4934,12 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt index 76f2bb8ff40..f8a63cacaf0 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt @@ -109,9 +109,11 @@ class IrInlineCodegen( ValueKind.DEFAULT_INLINE_PARAMETER else ValueKind.DEFAULT_PARAMETER - // TODO ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND? - isInlineParameter && irValueParameter.type.isSuspendFunctionTypeOrSubtype() -> - ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER + isInlineParameter && irValueParameter.type.isSuspendFunction() -> + if (argumentExpression.isReadOfInlineLambda()) + ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_PARAMETER_CALLED_IN_SUSPEND + else + ValueKind.NON_INLINEABLE_ARGUMENT_FOR_INLINE_SUSPEND_PARAMETER else -> ValueKind.GENERAL } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrUtils.kt index d4fbf8f8e35..26eeda9924d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/JvmIrUtils.kt @@ -95,7 +95,7 @@ fun IrFunction.getJvmVisibilityOfDefaultArgumentStub() = if (DescriptorVisibilities.isPrivate(visibility) || isInlineOnly()) JavaDescriptorVisibilities.PACKAGE_VISIBILITY else DescriptorVisibilities.PUBLIC fun IrValueParameter.isInlineParameter() = - index >= 0 && !isNoinline && (type.isFunction() || type.isSuspendFunctionTypeOrSubtype()) && + index >= 0 && !isNoinline && (type.isFunction() || type.isSuspendFunction()) && // Parameters with default values are always nullable, so check the expression too. // Note that the frontend has a diagnostic for nullable inline parameters, so actually // making this return `false` requires using `@Suppress`. diff --git a/compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt b/compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt new file mode 100644 index 00000000000..5b4033e5257 --- /dev/null +++ b/compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt @@ -0,0 +1,26 @@ +// WITH_COROUTINES +// WITH_RUNTIME +// IGNORE_BACKEND_MULTI_MODULE: JVM_MULTI_MODULE_OLD_AGAINST_IR +// FILE: test.kt +package test + +inline suspend fun f(crossinline x: suspend () -> Unit) = + object { suspend fun foo() = x() }.foo() + +// FILE: main.kt +import test.* +import kotlin.coroutines.* +import helpers.* + +inline suspend fun g(crossinline x: suspend () -> Unit) = + f(x) + +var result: String = "fail" + +inline suspend fun h(crossinline x: suspend () -> String) = + g { result = x() } + +fun box(): String { + suspend { h { "OK" } }.startCoroutine(EmptyContinuation) + return result +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index 8b1d622b4e8..961c32eacc2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -4904,6 +4904,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index ccb39b43de1..071d0eaa295 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4904,6 +4904,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index 432d2ff5692..76360782f2d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -4934,6 +4934,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 2e6103f65dd..f7ee1ae1f84 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4934,6 +4934,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java index fc4f0932762..6da50461d76 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4934,6 +4934,12 @@ public class IrSerializeCompileKotlinAgainstInlineKotlinTestGenerated extends Ab runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index 26291d1247b..28be14f20aa 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -4934,6 +4934,12 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index 3b032ba58f5..c996170cce8 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -4904,6 +4904,12 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @Test + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @Test @TestMetadata("inlineSuspendContinuation.kt") public void testInlineSuspendContinuation() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 275546a8f81..56d16b8486e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -3936,6 +3936,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt") public void testInlineSuspendOfCrossinlineOrdinary() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 5590f9cb9b8..62cd796fc8c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -3936,6 +3936,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt") public void testInlineSuspendOfCrossinlineOrdinary() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index bce70a6dd44..505ce97983e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -3936,6 +3936,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfNoinlineSuspend.kt"); } + @TestMetadata("inlinePassthrough.kt") + public void testInlinePassthrough() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/inlinePassthrough.kt"); + } + @TestMetadata("inlineSuspendOfCrossinlineOrdinary.kt") public void testInlineSuspendOfCrossinlineOrdinary() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/inlineSuspendOfCrossinlineOrdinary.kt");