JVM IR: IC coroutines: return boxed type from suspend function if
the function overrides function, returning type argument #KT-45451 Fixed
This commit is contained in:
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
interface EntityBase<out ID> {
|
||||
suspend fun id(): ID
|
||||
}
|
||||
|
||||
inline class EntityId(val value: String)
|
||||
|
||||
interface Entity : EntityBase<EntityId>
|
||||
|
||||
class EntityStub : Entity {
|
||||
override suspend fun id(): EntityId = EntityId("OK")
|
||||
}
|
||||
|
||||
suspend fun test(): EntityId {
|
||||
val entity: Entity = EntityStub()
|
||||
return entity.id()
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = "FAIL"
|
||||
builder {
|
||||
res = test().value
|
||||
}
|
||||
return res
|
||||
}
|
||||
Vendored
+37
@@ -0,0 +1,37 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
interface EntityBase<out ID> {
|
||||
suspend fun id(): ID
|
||||
}
|
||||
|
||||
inline class EntityId(val value: String)
|
||||
|
||||
interface Entity : EntityBase<EntityId>
|
||||
|
||||
var c: Continuation<EntityId>? = null
|
||||
|
||||
class EntityStub : Entity {
|
||||
override suspend fun id(): EntityId = suspendCoroutine { c = it }
|
||||
}
|
||||
|
||||
suspend fun test(): EntityId {
|
||||
val entity: Entity = EntityStub()
|
||||
return entity.id()
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
it.getOrThrow()
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var res = "FAIL"
|
||||
builder {
|
||||
res = test().value
|
||||
}
|
||||
c?.resume(EntityId("OK"))
|
||||
return res
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
interface EntityBase<out ID> {
|
||||
suspend fun id(): ID
|
||||
}
|
||||
|
||||
inline class EntityId(val value: String)
|
||||
|
||||
interface Entity : EntityBase<EntityId>
|
||||
|
||||
var res = "FAIL"
|
||||
|
||||
class EntityStub : Entity {
|
||||
override suspend fun id(): EntityId = error("OK")
|
||||
}
|
||||
|
||||
suspend fun test(): EntityId {
|
||||
val entity: Entity = EntityStub()
|
||||
return entity.id()
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(Continuation(EmptyCoroutineContext) {
|
||||
res = it.exceptionOrNull()!!.message!!
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
builder {
|
||||
test().value
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user