Skip to content

Commit 8d86066

Browse files
ilmirusSpace
authored andcommitted
Minor. Make test actually suspend and add a test without suspension
(cherry picked from commit f7a9bc3)
1 parent 739fdb1 commit 8d86066

File tree

11 files changed

+128
-7
lines changed

11 files changed

+128
-7
lines changed

compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// TARGET_BACKEND: JVM
2+
// WITH_RUNTIME
3+
// WITH_COROUTINES
4+
// FILE: a.kt
5+
@file:JvmMultifileClass
6+
@file:JvmName("A")
7+
8+
import kotlin.coroutines.*
9+
import kotlin.coroutines.intrinsics.*
10+
11+
@Suppress("UNSUPPORTED_FEATURE")
12+
inline class I(val x: Any?)
13+
14+
suspend fun <T> suspendHere(t: T): T = t
15+
16+
suspend fun f(): I = I(suspendHere("OK"))
17+
18+
// FILE: z.kt
19+
import helpers.*
20+
import kotlin.coroutines.*
21+
22+
fun box(): String {
23+
var result = "fail"
24+
suspend { result = f().x as String }.startCoroutine(EmptyContinuation)
25+
return result
26+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// WITH_RUNTIME
2+
// WITH_COROUTINES
3+
// IGNORE_BACKEND: JS_IR
4+
5+
import helpers.*
6+
import kotlin.coroutines.*
7+
import kotlin.coroutines.intrinsics.*
8+
9+
@Suppress("UNSUPPORTED_FEATURE")
10+
inline class I(val x: Any?)
11+
12+
class C {
13+
private suspend fun f(): I {
14+
return I("OK")
15+
}
16+
17+
fun g() = suspend { f() }
18+
}
19+
20+
val c: Continuation<Unit>? = null
21+
22+
fun box(): String {
23+
var result = "fail"
24+
suspend { result = C().g()().x as String }.startCoroutine(EmptyContinuation)
25+
26+
return result
27+
}

compiler/testData/codegen/box/coroutines/inlineClasses/resume/multifileBridge.kt

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// TARGET_PLATFORM: JVM
1+
// TARGET_BACKEND: JVM
22
// WITH_RUNTIME
33
// WITH_COROUTINES
44
// FILE: a.kt
@@ -11,12 +11,14 @@ import kotlin.coroutines.intrinsics.*
1111
@Suppress("UNSUPPORTED_FEATURE")
1212
inline class I(val x: Any?)
1313

14-
suspend fun <T> suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn {
15-
it.resume(x)
14+
suspend fun <T> suspendHere(): T = suspendCoroutineUninterceptedOrReturn {
15+
c = it as Continuation<Any?>
1616
COROUTINE_SUSPENDED
1717
}
1818

19-
suspend fun f(): I = I(suspendHere("OK"))
19+
var c: Continuation<Any?>? = null
20+
21+
suspend fun f(): I = I(suspendHere<String>())
2022

2123
// FILE: z.kt
2224
import helpers.*
@@ -25,5 +27,6 @@ import kotlin.coroutines.*
2527
fun box(): String {
2628
var result = "fail"
2729
suspend { result = f().x as String }.startCoroutine(EmptyContinuation)
30+
c?.resume("OK")
2831
return result
2932
}

compiler/testData/codegen/box/coroutines/inlineClasses/resume/syntheticAccessor.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,23 @@ import kotlin.coroutines.intrinsics.*
88
@Suppress("UNSUPPORTED_FEATURE")
99
inline class I(val x: Any?)
1010

11-
suspend fun <T> suspendHere(x: T): T = suspendCoroutineUninterceptedOrReturn {
12-
it.resume(x)
11+
suspend fun <T> suspendHere(): T = suspendCoroutineUninterceptedOrReturn {
12+
c = it as Continuation<Any?>
1313
COROUTINE_SUSPENDED
1414
}
1515

16+
var c: Continuation<Any?>? = null
17+
1618
class C {
17-
private suspend fun f(): I = I(suspendHere("OK"))
19+
private suspend fun f(): I = I(suspendHere<String>())
1820

1921
fun g() = suspend { f() }
2022
}
2123

2224
fun box(): String {
2325
var result = "fail"
2426
suspend { result = C().g()().x as String }.startCoroutine(EmptyContinuation)
27+
28+
c?.resume("OK")
2529
return result
2630
}

compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)