Fixed bug in SuspendFunctionsLowering + test
Supported callable references to non-local suspend functions.
This commit is contained in:
committed by
Igor Chevdar
parent
b93188a056
commit
57e75915ff
@@ -1324,6 +1324,11 @@ task coroutines_coroutineContext2(type: RunKonanTest) {
|
||||
source = "codegen/coroutines/coroutineContext2.kt"
|
||||
}
|
||||
|
||||
task coroutines_anonymousObject(type: RunKonanTest) {
|
||||
goldValue = "zzz\n"
|
||||
source = "codegen/coroutines/anonymousObject.kt"
|
||||
}
|
||||
|
||||
task AbstractMutableCollection(type: RunKonanTest) {
|
||||
expectedExitStatus = 0
|
||||
source = "runtime/collections/AbstractMutableCollection.kt"
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package codegen.coroutines.anonymousObject
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
open class EmptyContinuation(override val context: CoroutineContext = EmptyCoroutineContext) : Continuation<Any?> {
|
||||
companion object : EmptyContinuation()
|
||||
override fun resume(value: Any?) {}
|
||||
override fun resumeWithException(exception: Throwable) { throw exception }
|
||||
}
|
||||
|
||||
suspend fun suspendHere(): Int = suspendCoroutineOrReturn { x ->
|
||||
x.resume(42)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(EmptyContinuation)
|
||||
}
|
||||
|
||||
interface I {
|
||||
suspend fun foo(lambda: suspend (String) -> Unit)
|
||||
suspend fun bar(s: String)
|
||||
}
|
||||
|
||||
fun create() = object: I {
|
||||
var lambda: suspend (String) -> Unit = {}
|
||||
|
||||
override suspend fun foo(lambda: suspend (String) -> Unit) {
|
||||
this.lambda = lambda
|
||||
}
|
||||
|
||||
override suspend fun bar(s: String) {
|
||||
lambda(s)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun runTest() {
|
||||
builder {
|
||||
val z = create()
|
||||
z.foo { suspendHere(); println(it) }
|
||||
z.bar("zzz")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user