Fix assignment codegen for suspend operators plus and plusAssign
KT-16079: Fixed
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
suspend fun suspendThere(v: A): A = suspendCoroutineOrReturn { x ->
|
||||
x.resume(v)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
class A(var value: String) {
|
||||
operator suspend fun plus(other: A) = suspendThere(A(value + other.value))
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
suspend fun usePlusAssign(): A {
|
||||
var a = A("O")
|
||||
a += A("K")
|
||||
return a
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var a = A("")
|
||||
builder { a = usePlusAssign() }
|
||||
return a.value
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
suspend fun suspendThere(v: A): A = suspendCoroutineOrReturn { x ->
|
||||
x.resume(v)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
class A(var value: String) {
|
||||
operator suspend fun plusAssign(other: A) {
|
||||
value = suspendThere(A(value + other.value)).value
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
suspend fun usePlusAssign(): A {
|
||||
var a = A("O")
|
||||
a += A("K")
|
||||
return a
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var a = A("")
|
||||
builder { a = usePlusAssign() }
|
||||
return a.value
|
||||
}
|
||||
-2
@@ -1,9 +1,7 @@
|
||||
// IGNORE_BACKEND: JVM
|
||||
// WITH_RUNTIME
|
||||
// WITH_COROUTINES
|
||||
import helpers.*
|
||||
|
||||
// TODO: looks like this is a bug in JVM backend
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
Reference in New Issue
Block a user