JS: adapt to 1.3 coroutines API
Also update a line number test
This commit is contained in:
committed by
Ilya Gorbunov
parent
2d04acba42
commit
8975a6e17e
@@ -3,7 +3,7 @@
|
|||||||
// DECLARES_VARIABLE: function=doResume name=k
|
// DECLARES_VARIABLE: function=doResume name=k
|
||||||
// PROPERTY_READ_COUNT: name=local$o count=1
|
// PROPERTY_READ_COUNT: name=local$o count=1
|
||||||
// PROPERTY_WRITE_COUNT: name=local$o count=2
|
// PROPERTY_WRITE_COUNT: name=local$o count=2
|
||||||
import kotlin.coroutines.experimental.*
|
import kotlin.coroutines.*
|
||||||
|
|
||||||
var next: () -> Unit = {}
|
var next: () -> Unit = {}
|
||||||
var complete = false
|
var complete = false
|
||||||
@@ -19,11 +19,7 @@ fun build(x: suspend () -> Unit) {
|
|||||||
x.startCoroutine(object : Continuation<Unit> {
|
x.startCoroutine(object : Continuation<Unit> {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(x: Unit) {
|
override fun resumeWith(x: SuccessOrFailure<Unit>) {
|
||||||
complete = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun resumeWithException(x: Throwable) {
|
|
||||||
complete = true
|
complete = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
// IGNORE_BACKEND: JS_IR
|
// IGNORE_BACKEND: JS_IR
|
||||||
// EXPECTED_REACHABLE_NODES: 1250
|
// EXPECTED_REACHABLE_NODES: 1250
|
||||||
import kotlin.coroutines.experimental.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.experimental.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|
||||||
private var next: () -> Unit = {}
|
private var next: () -> Unit = {}
|
||||||
private var stopped = false
|
private var stopped = false
|
||||||
@@ -12,11 +12,7 @@ suspend fun delay(): Unit = suspendCoroutine { c ->
|
|||||||
|
|
||||||
fun build(c: suspend () -> Unit) {
|
fun build(c: suspend () -> Unit) {
|
||||||
c.startCoroutine(object : Continuation<Unit> {
|
c.startCoroutine(object : Continuation<Unit> {
|
||||||
override fun resume(x: Unit) {
|
override fun resumeWith(x: SuccessOrFailure<Unit>) {
|
||||||
stopped = true
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun resumeWithException(x: Throwable) {
|
|
||||||
stopped = true
|
stopped = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-5
@@ -2,8 +2,8 @@
|
|||||||
// EXPECTED_REACHABLE_NODES: 1172
|
// EXPECTED_REACHABLE_NODES: 1172
|
||||||
// FILE: a.kt
|
// FILE: a.kt
|
||||||
// WITH_RUNTIME
|
// WITH_RUNTIME
|
||||||
import kotlin.coroutines.experimental.*
|
import kotlin.coroutines.*
|
||||||
import kotlin.coroutines.experimental.intrinsics.*
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|
||||||
suspend fun suspendThere(v: String): String = suspendCoroutineOrReturn { x ->
|
suspend fun suspendThere(v: String): String = suspendCoroutineOrReturn { x ->
|
||||||
x.resume(v)
|
x.resume(v)
|
||||||
@@ -21,9 +21,7 @@ fun builder(c: suspend () -> Unit) {
|
|||||||
c.startCoroutine(object : Continuation<Unit> {
|
c.startCoroutine(object : Continuation<Unit> {
|
||||||
override val context = EmptyCoroutineContext
|
override val context = EmptyCoroutineContext
|
||||||
|
|
||||||
override fun resume(result: Unit) {}
|
override fun resumeWith(result: SuccessOrFailure<Unit>) {}
|
||||||
|
|
||||||
override fun resumeWithException(exception: Throwable) {}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
@@ -1,3 +1,4 @@
|
|||||||
|
// LANGUAGE_VERSION: 1.1
|
||||||
// EXPECTED_REACHABLE_NODES: 1112
|
// EXPECTED_REACHABLE_NODES: 1112
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -14,4 +14,4 @@ suspend fun bar(): Unit {
|
|||||||
println(a + b)
|
println(a + b)
|
||||||
}
|
}
|
||||||
|
|
||||||
// LINES: 4 4 4 5 5 5 5 6 4 4 4 15 9 9 9 9 15 9 9 9 * 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14
|
// LINES: 36 36 4 45 45 15 9 9 9 9 15 9 9 9 * 15 10 10 11 11 11 11 11 * 11 12 12 13 13 13 13 13 13 13 14 14
|
||||||
Reference in New Issue
Block a user