Implement basic support for coroutines in JVM backend

This commit is contained in:
Denis Zharkov
2016-05-25 14:46:38 +03:00
parent 077fc528d1
commit 75e112e752
30 changed files with 1151 additions and 45 deletions
@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE -UNUSED_VALUE -UNUSED_VARIABLE
class GenericController<T> {
operator fun handleResult(x: T, c: Continuation<Nothing>) { }
suspend fun <V> await(f: V, machine: Continuation<V>) {}
}
fun <T> genericBuilder(coroutine c: GenericController<T>.() -> Continuation<Unit>): T = null!!
fun foo() {
var result = ""
genericBuilder<String> {
try {
await("")
} catch(e: Exception) {
<!EXPECTED_TYPE_MISMATCH!>result = "fail"<!>
}
}
}
@@ -0,0 +1,13 @@
package
public fun foo(): kotlin.Unit
public fun </*0*/ T> genericBuilder(/*0*/ coroutine c: GenericController<T>.() -> kotlin.coroutines.Continuation<kotlin.Unit>): T
public final class GenericController</*0*/ T> {
public constructor GenericController</*0*/ T>()
public final suspend fun </*0*/ V> await(/*0*/ f: V, /*1*/ machine: kotlin.coroutines.Continuation<V>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final operator fun handleResult(/*0*/ x: T, /*1*/ c: kotlin.coroutines.Continuation<kotlin.Nothing>): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}