Add ContinuationAdapter to coroutine tests helpers
It allows having the same Continuation implementations for different API versions
This commit is contained in:
@@ -28,7 +28,7 @@ fun <T> asyncGenerate(block: suspend AsyncGenerator<T>.() -> Unit): AsyncSequenc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsyncGeneratorIterator<T>: AsyncIterator<T>, AsyncGenerator<T>, Continuation<Unit> {
|
class AsyncGeneratorIterator<T>: AsyncIterator<T>, AsyncGenerator<T>, ContinuationAdapter<Unit>() {
|
||||||
var computedNext = false
|
var computedNext = false
|
||||||
var nextValue: T? = null
|
var nextValue: T? = null
|
||||||
var nextStep: Continuation<Unit>? = null
|
var nextStep: Continuation<Unit>? = null
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fun <T> asyncGenerate(block: suspend AsyncGenerator<T>.() -> Unit): AsyncSequenc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsyncGeneratorIterator<T>: AsyncIterator<T>, AsyncGenerator<T>, Continuation<Unit> {
|
class AsyncGeneratorIterator<T>: AsyncIterator<T>, AsyncGenerator<T>, ContinuationAdapter<Unit>() {
|
||||||
var computedNext = false
|
var computedNext = false
|
||||||
var nextValue: T? = null
|
var nextValue: T? = null
|
||||||
var nextStep: Continuation<Unit>? = null
|
var nextStep: Continuation<Unit>? = null
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ fun <T> asyncGenerate(block: suspend AsyncGenerator<T>.() -> Unit): AsyncSequenc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AsyncGeneratorIterator<T>: AsyncIterator<T>, AsyncGenerator<T>, Continuation<Unit> {
|
class AsyncGeneratorIterator<T>: AsyncIterator<T>, AsyncGenerator<T>, ContinuationAdapter<Unit>() {
|
||||||
var computedNext = false
|
var computedNext = false
|
||||||
var nextValue: T? = null
|
var nextValue: T? = null
|
||||||
var nextStep: Continuation<Unit>? = null
|
var nextStep: Continuation<Unit>? = null
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ suspend fun suspendHere(): Any = suspendCoroutineOrReturn { x -> }
|
|||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
var exception: Throwable? = null
|
var exception: Throwable? = null
|
||||||
|
|
||||||
c.createCoroutine(object : Continuation<Unit> {
|
c.createCoroutine(object : ContinuationAdapter<Unit>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: Unit) {
|
override fun resume(data: Unit) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class Controller {
|
|||||||
|
|
||||||
fun builder(c: suspend Controller.() -> Unit): String {
|
fun builder(c: suspend Controller.() -> Unit): String {
|
||||||
val controller = Controller()
|
val controller = Controller()
|
||||||
c.startCoroutine(controller, object : Continuation<Unit> {
|
c.startCoroutine(controller, object : ContinuationAdapter<Unit>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: Unit) {
|
override fun resume(data: Unit) {
|
||||||
|
|||||||
+1
-1
@@ -20,7 +20,7 @@ class Controller {
|
|||||||
|
|
||||||
fun builder(c: suspend Controller.() -> Unit): String {
|
fun builder(c: suspend Controller.() -> Unit): String {
|
||||||
val controller = Controller()
|
val controller = Controller()
|
||||||
c.startCoroutine(controller, object : Continuation<Unit> {
|
c.startCoroutine(controller, object : ContinuationAdapter<Unit>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: Unit) {}
|
override fun resume(data: Unit) {}
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// IGNORE_BACKEND: JVM_IR
|
// IGNORE_BACKEND: JVM_IR
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
// IGNORE_BACKEND: JS
|
// IGNORE_BACKEND: JS
|
||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
import COROUTINES_PACKAGE.*
|
import COROUTINES_PACKAGE.*
|
||||||
@@ -9,7 +10,7 @@ import COROUTINES_PACKAGE.intrinsics.COROUTINE_SUSPENDED
|
|||||||
fun runCustomLambdaAsCoroutine(e: Throwable? = null, x: (Continuation<String>) -> Any?): String {
|
fun runCustomLambdaAsCoroutine(e: Throwable? = null, x: (Continuation<String>) -> Any?): String {
|
||||||
var result = "fail"
|
var result = "fail"
|
||||||
var wasIntercepted = false
|
var wasIntercepted = false
|
||||||
val c = (x as suspend () -> String).createCoroutine(object: Continuation<String> {
|
val c = (x as suspend () -> String).createCoroutine(object: ContinuationAdapter() {
|
||||||
override fun resumeWithException(exception: Throwable) {
|
override fun resumeWithException(exception: Throwable) {
|
||||||
throw exception
|
throw exception
|
||||||
}
|
}
|
||||||
@@ -27,7 +28,7 @@ fun runCustomLambdaAsCoroutine(e: Throwable? = null, x: (Continuation<String>) -
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <T> interceptContinuation(continuation: Continuation<T>) = object : Continuation<T> {
|
override fun <T> interceptContinuation(continuation: Continuation<T>) = object : helpers.ContinuationAdapter<T>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = continuation.context
|
get() = continuation.context
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -23,7 +23,7 @@ fun builder(c: suspend () -> Unit) {
|
|||||||
|
|
||||||
fun builderConsumer(c: suspend () -> Consumer): Consumer {
|
fun builderConsumer(c: suspend () -> Consumer): Consumer {
|
||||||
var res: Consumer? = null
|
var res: Consumer? = null
|
||||||
c.startCoroutine(object : Continuation<Consumer> {
|
c.startCoroutine(object : ContinuationAdapter<Consumer>() {
|
||||||
override fun resume(value: Consumer) {
|
override fun resume(value: Consumer) {
|
||||||
res = value
|
res = value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ abstract class ContinuationDispatcher : AbstractCoroutineContextElement(Continua
|
|||||||
private class DispatchedContinuation<T>(
|
private class DispatchedContinuation<T>(
|
||||||
val dispatcher: ContinuationDispatcher,
|
val dispatcher: ContinuationDispatcher,
|
||||||
val continuation: Continuation<T>
|
val continuation: Continuation<T>
|
||||||
): Continuation<T> {
|
): ContinuationAdapter<T>() {
|
||||||
override val context: CoroutineContext = continuation.context
|
override val context: CoroutineContext = continuation.context
|
||||||
|
|
||||||
override fun resume(value: T) {
|
override fun resume(value: T) {
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ class GeneratedSequence<out T>(private val block: suspend Generator<T>.() -> Uni
|
|||||||
}
|
}
|
||||||
|
|
||||||
class GeneratedIterator<T>(block: suspend Generator<T>.() -> Unit) : AbstractIterator<T>(), Generator<T> {
|
class GeneratedIterator<T>(block: suspend Generator<T>.() -> Unit) : AbstractIterator<T>(), Generator<T> {
|
||||||
private var nextStep: Continuation<Unit> = block.createCoroutine(this, object : Continuation<Unit> {
|
private var nextStep: Continuation<Unit> = block.createCoroutine(this, object : ContinuationAdapter<Unit>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: Unit) {
|
override fun resume(data: Unit) {
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ suspend fun multipleArgs(a: Any, b: Any, c: Any) =
|
|||||||
fun builder(c: suspend () -> String): String {
|
fun builder(c: suspend () -> String): String {
|
||||||
var fromSuspension: String? = null
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
val continuation = object : Continuation<String> {
|
val continuation = object : ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ class Controller {
|
|||||||
fun builder(c: suspend Controller.() -> String): String {
|
fun builder(c: suspend Controller.() -> String): String {
|
||||||
var fromSuspension: String? = null
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
c.startCoroutine(this, object : Continuation<String> {
|
c.startCoroutine(this, object : ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
@@ -61,4 +61,4 @@ fun box(): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+2
-2
@@ -27,7 +27,7 @@ class Controller {
|
|||||||
fun builder(c: suspend Controller.() -> String): String {
|
fun builder(c: suspend Controller.() -> String): String {
|
||||||
var fromSuspension: String? = null
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
c.startCoroutine(this, object : Continuation<String> {
|
c.startCoroutine(this, object : ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
@@ -60,4 +60,4 @@ fun box(): String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ fun builder(expectedCount: Int, c: suspend () -> String): String {
|
|||||||
var counter = 0
|
var counter = 0
|
||||||
|
|
||||||
val result = try {
|
val result = try {
|
||||||
c.startCoroutineUninterceptedOrReturn(object: Continuation<String> {
|
c.startCoroutineUninterceptedOrReturn(object: ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = ContinuationDispatcher { counter++ }
|
get() = ContinuationDispatcher { counter++ }
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ class ContinuationDispatcher(val dispatcher: () -> Unit) : AbstractCoroutineCont
|
|||||||
private class DispatchedContinuation<T>(
|
private class DispatchedContinuation<T>(
|
||||||
val dispatcher: () -> Unit,
|
val dispatcher: () -> Unit,
|
||||||
val continuation: Continuation<T>
|
val continuation: Continuation<T>
|
||||||
): Continuation<T> {
|
): ContinuationAdapter<T>() {
|
||||||
override val context: CoroutineContext = continuation.context
|
override val context: CoroutineContext = continuation.context
|
||||||
|
|
||||||
override fun resume(value: T) {
|
override fun resume(value: T) {
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ suspend fun suspendWithException(): String = suspendCoroutineOrReturn { x ->
|
|||||||
fun builder(c: suspend () -> String): String {
|
fun builder(c: suspend () -> String): String {
|
||||||
var fromSuspension: String? = null
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
c.startCoroutine(object: Continuation<String> {
|
c.startCoroutine(object: ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -22,7 +22,7 @@ fun builder(shouldSuspend: Boolean, c: suspend () -> String): String {
|
|||||||
var fromSuspension: String? = null
|
var fromSuspension: String? = null
|
||||||
|
|
||||||
val result = try {
|
val result = try {
|
||||||
c.startCoroutineUninterceptedOrReturn(object: Continuation<String> {
|
c.startCoroutineUninterceptedOrReturn(object: ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ fun builder(shouldSuspend: Boolean, expectedCount: Int, c: suspend () -> String)
|
|||||||
var counter = 0
|
var counter = 0
|
||||||
|
|
||||||
val result = try {
|
val result = try {
|
||||||
c.startCoroutineUninterceptedOrReturn(object: Continuation<String> {
|
c.startCoroutineUninterceptedOrReturn(object: ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = ContinuationDispatcher { counter++ }
|
get() = ContinuationDispatcher { counter++ }
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class ContinuationDispatcher(val dispatcher: () -> Unit) : AbstractCoroutineCont
|
|||||||
private class DispatchedContinuation<T>(
|
private class DispatchedContinuation<T>(
|
||||||
val dispatcher: () -> Unit,
|
val dispatcher: () -> Unit,
|
||||||
val continuation: Continuation<T>
|
val continuation: Continuation<T>
|
||||||
): Continuation<T> {
|
): ContinuationAdapter<T>() {
|
||||||
override val context: CoroutineContext = continuation.context
|
override val context: CoroutineContext = continuation.context
|
||||||
|
|
||||||
override fun resume(value: T) {
|
override fun resume(value: T) {
|
||||||
|
|||||||
compiler/testData/codegen/box/coroutines/intrinsicSemantics/suspendCoroutineUninterceptedOrReturn.kt
Vendored
+2
-2
@@ -23,7 +23,7 @@ fun builder(shouldSuspend: Boolean, c: suspend () -> String): String {
|
|||||||
var counter = 0
|
var counter = 0
|
||||||
|
|
||||||
val result = try {
|
val result = try {
|
||||||
c.startCoroutineUninterceptedOrReturn(object: Continuation<String> {
|
c.startCoroutineUninterceptedOrReturn(object: ContinuationAdapter<String>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = ContinuationDispatcher { counter++ }
|
get() = ContinuationDispatcher { counter++ }
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ class ContinuationDispatcher(val dispatcher: () -> Unit) : AbstractCoroutineCont
|
|||||||
private class DispatchedContinuation<T>(
|
private class DispatchedContinuation<T>(
|
||||||
val dispatcher: () -> Unit,
|
val dispatcher: () -> Unit,
|
||||||
val continuation: Continuation<T>
|
val continuation: Continuation<T>
|
||||||
): Continuation<T> {
|
): ContinuationAdapter<T>() {
|
||||||
override val context: CoroutineContext = continuation.context
|
override val context: CoroutineContext = continuation.context
|
||||||
|
|
||||||
override fun resume(value: T) {
|
override fun resume(value: T) {
|
||||||
|
|||||||
+1
-1
@@ -32,7 +32,7 @@ suspend fun callLocal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
val continuation = object: Continuation<Unit> {
|
val continuation = object: ContinuationAdapter<Unit>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ suspend fun sleep(): Unit = suspendCoroutine { c ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun async(f: suspend () -> Unit) {
|
fun async(f: suspend () -> Unit) {
|
||||||
f.startCoroutine(object : Continuation<Unit> {
|
f.startCoroutine(object : ContinuationAdapter<Unit>() {
|
||||||
override fun resume(x: Unit) {
|
override fun resume(x: Unit) {
|
||||||
proceed = {
|
proceed = {
|
||||||
result += "done;"
|
result += "done;"
|
||||||
@@ -63,7 +63,7 @@ fun async(f: suspend () -> Unit) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun asyncSuspend(f: suspend () -> Unit) {
|
fun asyncSuspend(f: suspend () -> Unit) {
|
||||||
val coroutine = f.createCoroutine(object : Continuation<Unit> {
|
val coroutine = f.createCoroutine(object : ContinuationAdapter<Unit>() {
|
||||||
override fun resume(x: Unit) {
|
override fun resume(x: Unit) {
|
||||||
proceed = {
|
proceed = {
|
||||||
result += "done;"
|
result += "done;"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
|||||||
fun builder(c: suspend () -> Int): Int {
|
fun builder(c: suspend () -> Int): Int {
|
||||||
var res = 0
|
var res = 0
|
||||||
|
|
||||||
c.createCoroutine(object : Continuation<Int> {
|
c.createCoroutine(object : ContinuationAdapter<Int>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: Int) {
|
override fun resume(data: Int) {
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ abstract class ContinuationDispatcher : AbstractCoroutineContextElement(Continua
|
|||||||
private class DispatchedContinuation<T>(
|
private class DispatchedContinuation<T>(
|
||||||
val dispatcher: ContinuationDispatcher,
|
val dispatcher: ContinuationDispatcher,
|
||||||
val continuation: Continuation<T>
|
val continuation: Continuation<T>
|
||||||
): Continuation<T> {
|
): ContinuationAdapter<T>() {
|
||||||
override val context: CoroutineContext = continuation.context
|
override val context: CoroutineContext = continuation.context
|
||||||
|
|
||||||
override fun resume(value: T) {
|
override fun resume(value: T) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ suspend fun bar(x: Int): Int = suspendCoroutine { c ->
|
|||||||
inline suspend fun foo(x: Int) = bar(x)
|
inline suspend fun foo(x: Int) = bar(x)
|
||||||
|
|
||||||
fun async(a: suspend () -> Unit) {
|
fun async(a: suspend () -> Unit) {
|
||||||
a.startCoroutine(object : Continuation<Unit> {
|
a.startCoroutine(object : ContinuationAdapter<Unit>() {
|
||||||
override fun resume(value: Unit) {
|
override fun resume(value: Unit) {
|
||||||
proceed = {
|
proceed = {
|
||||||
log("done")
|
log("done")
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
|||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
var wasResumeCalled = false
|
var wasResumeCalled = false
|
||||||
c.startCoroutine(object : Continuation<Unit> {
|
c.startCoroutine(object : ContinuationAdapter<Unit>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(value: Unit) {
|
override fun resume(value: Unit) {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ suspend fun suspendHere(): String = suspendCoroutineOrReturn { x ->
|
|||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
var wasResumeCalled = false
|
var wasResumeCalled = false
|
||||||
c.startCoroutine(object : Continuation<Unit> {
|
c.startCoroutine(object : ContinuationAdapter<Unit>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(value: Unit) {
|
override fun resume(value: Unit) {
|
||||||
|
|||||||
@@ -7,16 +7,14 @@ inline suspend fun foo(x: suspend () -> String) = x()
|
|||||||
|
|
||||||
// FILE: box.kt
|
// FILE: box.kt
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
|
|
||||||
import COROUTINES_PACKAGE.*
|
import COROUTINES_PACKAGE.*
|
||||||
import COROUTINES_PACKAGE.intrinsics.*
|
import COROUTINES_PACKAGE.intrinsics.*
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
c.startCoroutine(object: Continuation<Unit> {
|
c.startCoroutine(object: helpers.ContinuationAdapter<Unit>() {
|
||||||
override val context: CoroutineContext
|
|
||||||
get() = EmptyCoroutineContext
|
|
||||||
|
|
||||||
override fun resume(value: Unit) {
|
override fun resume(value: Unit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
// IGNORE_BACKEND: JVM_IR
|
||||||
// FILE: inlined.kt
|
// FILE: inlined.kt
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
// NO_CHECK_LAMBDA_INLINING
|
// NO_CHECK_LAMBDA_INLINING
|
||||||
|
|
||||||
import kotlin.coroutines.experimental.*
|
import kotlin.coroutines.experimental.*
|
||||||
@@ -33,7 +34,7 @@ import kotlin.coroutines.experimental.*
|
|||||||
import kotlin.coroutines.experimental.intrinsics.*
|
import kotlin.coroutines.experimental.intrinsics.*
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
val continuation = object: Continuation<Unit> {
|
val continuation = object: helpers.ContinuationAdapter<Unit>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
@@ -69,4 +70,4 @@ fun box(): String {
|
|||||||
proceed()
|
proceed()
|
||||||
if (!finished) return "resume on root continuation is not called"
|
if (!finished) return "resume on root continuation is not called"
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -1,6 +1,7 @@
|
|||||||
// IGNORE_BACKEND: JVM_IR
|
// IGNORE_BACKEND: JVM_IR
|
||||||
// FILE: inlined.kt
|
// FILE: inlined.kt
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
// NO_CHECK_LAMBDA_INLINING
|
// NO_CHECK_LAMBDA_INLINING
|
||||||
|
|
||||||
import kotlin.coroutines.experimental.*
|
import kotlin.coroutines.experimental.*
|
||||||
@@ -31,7 +32,7 @@ import kotlin.coroutines.experimental.*
|
|||||||
import kotlin.coroutines.experimental.intrinsics.*
|
import kotlin.coroutines.experimental.intrinsics.*
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
val continuation = object: Continuation<Unit> {
|
val continuation = object: helpers.ContinuationAdapter<Unit>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
@@ -67,4 +68,4 @@ fun box(): String {
|
|||||||
proceed()
|
proceed()
|
||||||
if (!finished) return "resume on root continuation is not called"
|
if (!finished) return "resume on root continuation is not called"
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,6 +1,7 @@
|
|||||||
// FILE: inlined.kt
|
// FILE: inlined.kt
|
||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
// NO_CHECK_LAMBDA_INLINING
|
// NO_CHECK_LAMBDA_INLINING
|
||||||
|
|
||||||
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
suspend inline fun crossinlineMe(crossinline c: suspend () -> Unit) {
|
||||||
@@ -17,6 +18,7 @@ suspend inline fun crossinlineMe2(crossinline c: suspend () -> Unit) {
|
|||||||
|
|
||||||
import COROUTINES_PACKAGE.*
|
import COROUTINES_PACKAGE.*
|
||||||
import COROUTINES_PACKAGE.intrinsics.*
|
import COROUTINES_PACKAGE.intrinsics.*
|
||||||
|
import helpers.*
|
||||||
|
|
||||||
var result = "FAIL"
|
var result = "FAIL"
|
||||||
var i = 0
|
var i = 0
|
||||||
@@ -30,7 +32,7 @@ suspend fun suspendHere() = suspendCoroutine<Unit> { c ->
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun builder(c: suspend () -> Unit) {
|
fun builder(c: suspend () -> Unit) {
|
||||||
val continuation = object: Continuation<Unit> {
|
val continuation = object: ContinuationAdapter<Unit>() {
|
||||||
override val context: CoroutineContext
|
override val context: CoroutineContext
|
||||||
get() = EmptyCoroutineContext
|
get() = EmptyCoroutineContext
|
||||||
|
|
||||||
@@ -67,4 +69,4 @@ fun box(): String {
|
|||||||
proceed()
|
proceed()
|
||||||
if (!finished) return "resume on root continuation is not called"
|
if (!finished) return "resume on root continuation is not called"
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
// WITH_COROUTINES
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import COROUTINES_PACKAGE.*
|
import COROUTINES_PACKAGE.*
|
||||||
@@ -48,7 +49,7 @@ fun box(): String {
|
|||||||
|
|
||||||
fun <T> async(c: suspend () -> T): CompletableFuture<T> {
|
fun <T> async(c: suspend () -> T): CompletableFuture<T> {
|
||||||
val future = CompletableFuture<T>()
|
val future = CompletableFuture<T>()
|
||||||
c.startCoroutine(object : Continuation<T> {
|
c.startCoroutine(object : helpers.ContinuationAdapter<T>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: T) {
|
override fun resume(data: T) {
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
// FULL_JDK
|
// FULL_JDK
|
||||||
|
// WITH_COROUTINES
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture
|
import java.util.concurrent.CompletableFuture
|
||||||
import COROUTINES_PACKAGE.*
|
import COROUTINES_PACKAGE.*
|
||||||
@@ -45,7 +46,7 @@ fun box(): String {
|
|||||||
|
|
||||||
fun <T> async(c: suspend () -> T): CompletableFuture<T> {
|
fun <T> async(c: suspend () -> T): CompletableFuture<T> {
|
||||||
val future = CompletableFuture<T>()
|
val future = CompletableFuture<T>()
|
||||||
c.startCoroutine(object : Continuation<T> {
|
c.startCoroutine(object : helpers.ContinuationAdapter<T>() {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(data: T) {
|
override fun resume(data: T) {
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// COMMON_COROUTINES_TEST
|
// COMMON_COROUTINES_TEST
|
||||||
// FILE: A.kt
|
// FILE: A.kt
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
package a
|
package a
|
||||||
|
|
||||||
import COROUTINES_PACKAGE.*
|
import COROUTINES_PACKAGE.*
|
||||||
@@ -15,7 +16,7 @@ class Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun builder(c: suspend Controller.() -> Unit) {
|
fun builder(c: suspend Controller.() -> Unit) {
|
||||||
c.startCoroutine(Controller(), object : Continuation<Unit> {
|
c.startCoroutine(Controller(), object : helpers.ContinuationAdapter<Unit>() {
|
||||||
override val context: CoroutineContext = EmptyCoroutineContext
|
override val context: CoroutineContext = EmptyCoroutineContext
|
||||||
override fun resume(value: Unit) {}
|
override fun resume(value: Unit) {}
|
||||||
|
|
||||||
|
|||||||
@@ -34,5 +34,9 @@ fun createTextForHelpers(coroutinesPackage: String): String {
|
|||||||
| override fun resume(data: Any?) {}
|
| override fun resume(data: Any?) {}
|
||||||
| override fun resumeWithException(exception: Throwable) { throw exception }
|
| override fun resumeWithException(exception: Throwable) { throw exception }
|
||||||
|}
|
|}
|
||||||
|
|
|
||||||
|
|abstract class ContinuationAdapter<in T> : Continuation<T> {
|
||||||
|
| override val context: CoroutineContext = EmptyCoroutineContext
|
||||||
|
|}
|
||||||
""".trimMargin()
|
""".trimMargin()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user