Generate return when generating continuation class for expression body

Otherwise, the function will return Unit instead of correct value.
 #KT-46007 Fixed
This commit is contained in:
Ilmir Usmanov
2021-04-14 17:47:50 +02:00
committed by TeamCityServer
parent 539d3e5df2
commit 1c48fb28db
13 changed files with 399 additions and 25 deletions
@@ -0,0 +1,30 @@
// WITH_RUNTIME
// !JVM_DEFAULT_MODE: all-compatibility
// TARGET_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
// IGNORE_BACKEND: JVM
// JVM_TARGET: 1.8
import kotlin.coroutines.*
class A : BlockingDoubleChain
interface BlockingDoubleChain : BlockingBufferChain
interface BlockingBufferChain {
suspend fun nextBuffer(): String = "OK"
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(Continuation(EmptyCoroutineContext) {
it.getOrThrow()
})
}
fun box(): String {
var res = "FAIL"
builder {
res = A().nextBuffer()
}
return res
}
@@ -0,0 +1,28 @@
// WITH_RUNTIME
// !JVM_DEFAULT_MODE: all
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
import kotlin.coroutines.*
class A : BlockingDoubleChain
interface BlockingDoubleChain : BlockingBufferChain
interface BlockingBufferChain {
suspend fun nextBuffer(): String = "OK"
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(Continuation(EmptyCoroutineContext) {
it.getOrThrow()
})
}
fun box(): String {
var res = "FAIL"
builder {
res = A().nextBuffer()
}
return res
}
@@ -0,0 +1,28 @@
// WITH_RUNTIME
// !JVM_DEFAULT_MODE: disable
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
import kotlin.coroutines.*
class A : BlockingDoubleChain
interface BlockingDoubleChain : BlockingBufferChain
interface BlockingBufferChain {
suspend fun nextBuffer(): String = "OK"
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(Continuation(EmptyCoroutineContext) {
it.getOrThrow()
})
}
fun box(): String {
var res = "FAIL"
builder {
res = A().nextBuffer()
}
return res
}
@@ -0,0 +1,28 @@
// WITH_RUNTIME
// !JVM_DEFAULT_MODE: enable
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
import kotlin.coroutines.*
class A : BlockingDoubleChain
interface BlockingDoubleChain : BlockingBufferChain
interface BlockingBufferChain {
suspend fun nextBuffer(): String = "OK"
}
fun builder(c: suspend () -> Unit) {
c.startCoroutine(Continuation(EmptyCoroutineContext) {
it.getOrThrow()
})
}
fun box(): String {
var res = "FAIL"
builder {
res = A().nextBuffer()
}
return res
}