diff --git a/compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt b/compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt new file mode 100644 index 00000000000..e013e9714b0 --- /dev/null +++ b/compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt @@ -0,0 +1,31 @@ +// WITH_RUNTIME +// WITH_COROUTINES +// NO_CHECK_LAMBDA_INLINING +// FILE: 1.kt +package test + +import kotlin.coroutines.* + +suspend fun callMe(): String = "OK" + +inline suspend fun isSuspend(t: T): Boolean = t is (SuspendFunction0<*>) + +inline suspend fun callSuspend(t: T): String = (t as (suspend () -> String))() + +// FILE: 2.kt + +import helpers.* +import test.* +import kotlin.coroutines.* + +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/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt b/compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt new file mode 100644 index 00000000000..85254e64c69 --- /dev/null +++ b/compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt @@ -0,0 +1,34 @@ +// WITH_RUNTIME +// WITH_COROUTINES +// NO_CHECK_LAMBDA_INLINING +// FILE: 1.kt +package test + +import kotlin.coroutines.* + +inline fun Any?.instanceOf() = this is T + +inline suspend fun String> T.callSuspend(): String = (this as (suspend () -> String))() + +// FILE: 2.kt + +import helpers.* +import test.* +import kotlin.coroutines.* + +fun Any?.isSuspend(): Boolean = instanceOf String>() +fun callMe(): String = "OK" +fun makeSuspend(x: suspend () -> String) = x + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun box(): String { + var res = "FAIL" + builder { + val adapted = makeSuspend(::callMe) + res = if (adapted.isSuspend()) adapted.callSuspend() else "!isSuspend" + } + return res +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index d4995cf85a8..66d25d36d25 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -4070,6 +4070,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index c9efac6fcbd..bcc3fdd4915 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4070,6 +4070,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 9477afd7221..dcd672b0dea 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -3960,6 +3960,16 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index dd8fb1ece1c..33ce7ec810f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3960,6 +3960,16 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java index 84ed9fee1ec..16973039a59 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -3960,6 +3960,16 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java index 1130c931085..59adecc31ad 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -3960,6 +3960,16 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 70f62d5d9f0..ff4b8bbb76e 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -3515,6 +3515,16 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 53ce9862ff1..094b6945f4a 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -3515,6 +3515,16 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 4807256df14..ea335b3fa86 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -3515,6 +3515,16 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/callableReference"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("isAsReified.kt") + public void testIsAsReified() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified.kt"); + } + + @TestMetadata("isAsReified2.kt") + public void testIsAsReified2() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/callableReference/isAsReified2.kt"); + } + @TestMetadata("nonTailCall.kt") public void testNonTailCall() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/callableReference/nonTailCall.kt");