diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 49a62b57034..3ee90b681db 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -10765,6 +10765,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/suspendImplBridge.kt"); } + @Test + @TestMetadata("suspendImplTypeParameters.kt") + public void testSuspendImplTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/suspendImplTypeParameters.kt"); + } + @Test @TestMetadata("suspendInCycle.kt") public void testSuspendInCycle() throws Exception { diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index 021ec6af9d5..3dacf726a0f 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -225,7 +225,8 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower else JavaDescriptorVisibilities.PACKAGE_VISIBILITY, isFakeOverride = false, - copyMetadata = false + copyMetadata = false, + typeParametersFromContext = irFunction.parentAsClass.typeParameters, ) static.body = irFunction.moveBodyTo(static) // Fixup dispatch parameter to outer class diff --git a/compiler/testData/codegen/box/coroutines/suspendImplTypeParameters.kt b/compiler/testData/codegen/box/coroutines/suspendImplTypeParameters.kt new file mode 100644 index 00000000000..78a3396a9ba --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/suspendImplTypeParameters.kt @@ -0,0 +1,20 @@ +// TARGET_BACKEND: JVM_IR +// WITH_STDLIB +// FULL_JDK + +abstract class AbstractPersistence { + open suspend fun fetch(identifier: U): T? = null +} + +fun box(): String { + val genericString = + AbstractPersistence::class.java.declaredMethods + .single { it.name.contains("\$suspendImpl") } + .toGenericString() + + if (!genericString.startsWith("static ")) { + return genericString + } + + return "OK" +} 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 f8e9a83367f..26ab8d2d74d 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 @@ -10765,6 +10765,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/suspendImplBridge.kt"); } + @Test + @TestMetadata("suspendImplTypeParameters.kt") + public void testSuspendImplTypeParameters() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/suspendImplTypeParameters.kt"); + } + @Test @TestMetadata("suspendInCycle.kt") public void testSuspendInCycle() throws Exception {