diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.kt index a6e32c1f5da..41300265001 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/JvmRuntimeTypes.kt @@ -162,7 +162,7 @@ class JvmRuntimeTypes( referencedFunction.isSuspend || isSuspendConversion ) - val suspendFunctionType = if (referencedFunction.isSuspend) suspendFunctionInterface?.defaultType else null + val suspendFunctionType = if (referencedFunction.isSuspend || isSuspendConversion) suspendFunctionInterface?.defaultType else null val superClass = when { generateOptimizedCallableReferenceSuperClasses -> when { isAdaptedCallableReference || isSuspendConversion -> adaptedFunctionReference diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 9ecb79b7683..22e2171c965 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -2227,6 +2227,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt"); diff --git a/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt b/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt new file mode 100644 index 00000000000..df9f1d7a009 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: +SuspendConversion +// WITH_RUNTIME +// WITH_COROUTINES + +import helpers.* +import kotlin.coroutines.* + +fun callMe(): String = "OK" + +suspend fun isSuspend(c: suspend () -> String) = c is suspend () -> String +suspend fun callSuspend(c: suspend () -> String) = (c as suspend () -> String)() + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun box(): String { + var res = "FAIL" + builder { + res = if (isSuspend(::callMe)) callSuspend(::callMe) else "!isSuspend" + } + return res +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index c91ab5a5bee..a118b4ccc18 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2247,6 +2247,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 691a5928d52..a1bdcd49624 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2247,6 +2247,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 41bd8030c2c..c07cb2cab4a 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -2227,6 +2227,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 94edfe2f408..093c8ce7af9 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -1642,6 +1642,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 293938cfe35..fe88e653616 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1642,6 +1642,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index dfef036fbf2..fa1b3c1b08c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1642,6 +1642,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/inlineWithParameters.kt"); } + @TestMetadata("isAs.kt") + public void testIsAs() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/isAs.kt"); + } + @TestMetadata("simple.kt") public void testSimple() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/suspendConversion/simple.kt");