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:
committed by
TeamCityServer
parent
539d3e5df2
commit
1c48fb28db
compiler/testData/codegen/box/coroutines/featureIntersection/jvmDefault/kt46007/all-compatibility.kt
Vendored
+30
@@ -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
|
||||
}
|
||||
+28
@@ -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
|
||||
}
|
||||
+28
@@ -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
|
||||
}
|
||||
+28
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user