From f7a9bc3521de64177419257a230dfee3f6e24aaa Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Thu, 22 Apr 2021 13:26:27 +0200 Subject: [PATCH] Minor. Make test actually suspend and add a test without suspension --- .../FirBlackBoxCodegenTestGenerated.java | 12 +++++++++ .../inlineClasses/direct/multifileBridge.kt | 26 ++++++++++++++++++ .../inlineClasses/direct/syntheticAccessor.kt | 27 +++++++++++++++++++ .../inlineClasses/resume/multifileBridge.kt | 11 +++++--- .../inlineClasses/resume/syntheticAccessor.kt | 10 ++++--- .../codegen/BlackBoxCodegenTestGenerated.java | 12 +++++++++ .../IrBlackBoxCodegenTestGenerated.java | 12 +++++++++ .../LightAnalysisModeTestGenerated.java | 10 +++++++ .../IrJsCodegenBoxES6TestGenerated.java | 5 ++++ .../IrJsCodegenBoxTestGenerated.java | 5 ++++ .../semantics/JsCodegenBoxTestGenerated.java | 5 ++++ 11 files changed, 128 insertions(+), 7 deletions(-) create mode 100644 compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt create mode 100644 compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt 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 7999547c837..6565c3d7d5f 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 @@ -10328,6 +10328,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/invokeOperator.kt"); } + @Test + @TestMetadata("multifileBridge.kt") + public void testMultifileBridge() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt"); + } + @Test @TestMetadata("overrideSuspendFun.kt") public void testOverrideSuspendFun() throws Exception { @@ -10363,6 +10369,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @Test + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @Nested diff --git a/compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt b/compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt new file mode 100644 index 00000000000..47a5ed99d4c --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt @@ -0,0 +1,26 @@ +// TARGET_BACKEND: JVM +// WITH_RUNTIME +// WITH_COROUTINES +// FILE: a.kt +@file:JvmMultifileClass +@file:JvmName("A") + +import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* + +@Suppress("UNSUPPORTED_FEATURE") +inline class I(val x: Any?) + +suspend fun suspendHere(t: T): T = t + +suspend fun f(): I = I(suspendHere("OK")) + +// FILE: z.kt +import helpers.* +import kotlin.coroutines.* + +fun box(): String { + var result = "fail" + suspend { result = f().x as String }.startCoroutine(EmptyContinuation) + return result +} diff --git a/compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt b/compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt new file mode 100644 index 00000000000..039623d11b7 --- /dev/null +++ b/compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt @@ -0,0 +1,27 @@ +// WITH_RUNTIME +// WITH_COROUTINES +// IGNORE_BACKEND: JS_IR + +import helpers.* +import kotlin.coroutines.* +import kotlin.coroutines.intrinsics.* + +@Suppress("UNSUPPORTED_FEATURE") +inline class I(val x: Any?) + +class C { + private suspend fun f(): I { + return I("OK") + } + + fun g() = suspend { f() } +} + +val c: Continuation? = null + +fun box(): String { + var result = "fail" + suspend { result = C().g()().x as String }.startCoroutine(EmptyContinuation) + + return result +} diff --git a/compiler/testData/codegen/box/coroutines/inlineClasses/resume/multifileBridge.kt b/compiler/testData/codegen/box/coroutines/inlineClasses/resume/multifileBridge.kt index 475768eb1c6..e835e428cbd 100644 --- a/compiler/testData/codegen/box/coroutines/inlineClasses/resume/multifileBridge.kt +++ b/compiler/testData/codegen/box/coroutines/inlineClasses/resume/multifileBridge.kt @@ -1,4 +1,4 @@ -// TARGET_PLATFORM: JVM +// TARGET_BACKEND: JVM // WITH_RUNTIME // WITH_COROUTINES // FILE: a.kt @@ -11,12 +11,14 @@ import kotlin.coroutines.intrinsics.* @Suppress("UNSUPPORTED_FEATURE") inline class I(val x: Any?) -suspend fun suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn { - it.resume(x) +suspend fun suspendHere(): T = suspendCoroutineUninterceptedOrReturn { + c = it as Continuation COROUTINE_SUSPENDED } -suspend fun f(): I = I(suspendHere("OK")) +var c: Continuation? = null + +suspend fun f(): I = I(suspendHere()) // FILE: z.kt import helpers.* @@ -25,5 +27,6 @@ import kotlin.coroutines.* fun box(): String { var result = "fail" suspend { result = f().x as String }.startCoroutine(EmptyContinuation) + c?.resume("OK") return result } diff --git a/compiler/testData/codegen/box/coroutines/inlineClasses/resume/syntheticAccessor.kt b/compiler/testData/codegen/box/coroutines/inlineClasses/resume/syntheticAccessor.kt index 0335a3b94fd..445db333ad4 100644 --- a/compiler/testData/codegen/box/coroutines/inlineClasses/resume/syntheticAccessor.kt +++ b/compiler/testData/codegen/box/coroutines/inlineClasses/resume/syntheticAccessor.kt @@ -8,13 +8,15 @@ import kotlin.coroutines.intrinsics.* @Suppress("UNSUPPORTED_FEATURE") inline class I(val x: Any?) -suspend fun suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn { - it.resume(x) +suspend fun suspendHere(): T = suspendCoroutineUninterceptedOrReturn { + c = it as Continuation COROUTINE_SUSPENDED } +var c: Continuation? = null + class C { - private suspend fun f(): I = I(suspendHere("OK")) + private suspend fun f(): I = I(suspendHere()) fun g() = suspend { f() } } @@ -22,5 +24,7 @@ class C { fun box(): String { var result = "fail" suspend { result = C().g()().x as String }.startCoroutine(EmptyContinuation) + + c?.resume("OK") return result } 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 16d1d44b078..ae4d60c8b1d 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 @@ -10328,6 +10328,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/invokeOperator.kt"); } + @Test + @TestMetadata("multifileBridge.kt") + public void testMultifileBridge() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt"); + } + @Test @TestMetadata("overrideSuspendFun.kt") public void testOverrideSuspendFun() throws Exception { @@ -10363,6 +10369,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @Test + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @Nested 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 ee78e03410d..d131e6e80f2 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 @@ -10328,6 +10328,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/invokeOperator.kt"); } + @Test + @TestMetadata("multifileBridge.kt") + public void testMultifileBridge() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt"); + } + @Test @TestMetadata("overrideSuspendFun.kt") public void testOverrideSuspendFun() throws Exception { @@ -10363,6 +10369,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @Test + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @Nested diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 9b89fe0757d..7768c6ed4b3 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -8181,6 +8181,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/invokeOperator.kt"); } + @TestMetadata("multifileBridge.kt") + public void testMultifileBridge() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/multifileBridge.kt"); + } + @TestMetadata("overrideSuspendFun.kt") public void testOverrideSuspendFun() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/overrideSuspendFun.kt"); @@ -8210,6 +8215,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @TestMetadata("compiler/testData/codegen/box/coroutines/inlineClasses/resume") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 62b681270ed..fbe6753b1a2 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -7354,6 +7354,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @TestMetadata("compiler/testData/codegen/box/coroutines/inlineClasses/resume") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 0f6a021fb0c..5d9b7a8b390 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -6765,6 +6765,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @TestMetadata("compiler/testData/codegen/box/coroutines/inlineClasses/resume") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 21ea7ee103e..2e108c52d94 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -6765,6 +6765,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { public void testReturnResult() throws Exception { runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/returnResult.kt"); } + + @TestMetadata("syntheticAccessor.kt") + public void testSyntheticAccessor() throws Exception { + runTest("compiler/testData/codegen/box/coroutines/inlineClasses/direct/syntheticAccessor.kt"); + } } @TestMetadata("compiler/testData/codegen/box/coroutines/inlineClasses/resume")