Fix assignment codegen for suspend operators plus and plusAssign

KT-16079: Fixed
This commit is contained in:
Ilmir Usmanov
2017-11-01 16:40:18 +03:00
parent fbe274ff09
commit f4e180556c
8 changed files with 160 additions and 51 deletions
@@ -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
}
@@ -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
}
@@ -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.*