Replace common extension receiver of coroutine-lambda with magic one
Currently it only contains additional synthetic declarations for suspend-functions E.g. `fun <V> await(f: CompletableFuture<V>): V` for `fun <V> await(f: CompletableFuture<V>, machine: Continuation<V>): Unit`
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
class Controller {
|
||||
suspend fun noParams(c: Continuation<Unit>) {
|
||||
|
||||
}
|
||||
suspend fun yieldString(value: String, c: Continuation<Unit>) {
|
||||
}
|
||||
|
||||
suspend fun <V> await(f: () -> V, machine: Continuation<V>) {
|
||||
}
|
||||
|
||||
suspend fun <V> await(f: Int, machine: Continuation<V>) {
|
||||
}
|
||||
|
||||
suspend fun severalParams(x: String, y: Int, machine: Continuation<Double>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(coroutine c: Controller.() -> Continuation<Unit>) {}
|
||||
|
||||
fun test() {
|
||||
builder {
|
||||
noParams()
|
||||
yieldString("abc") checkType { _<Unit>() }
|
||||
yieldString(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>) checkType { _<Unit>() }
|
||||
|
||||
await<String> { "123" } checkType { _<String>() }
|
||||
|
||||
// Inference from lambda return type
|
||||
await { 123 } checkType { _<Int>() }
|
||||
|
||||
// Inference from expected type
|
||||
checkSubtype<String>(await(567))
|
||||
|
||||
await<Double>(123) checkType { _<Double>() }
|
||||
|
||||
severalParams("", 89) checkType { _<Double>() }
|
||||
// TODO: prohibit such calls
|
||||
severalParams("", 89, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>6.9<!>) checkType { _<Unit>() }
|
||||
severalParams("", 89, this <!CAST_NEVER_SUCCEEDS!>as<!> Continuation<Double>) checkType { _<Unit>() }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package
|
||||
|
||||
public fun builder(/*0*/ coroutine c: Controller.() -> kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class Controller {
|
||||
public constructor Controller()
|
||||
public final suspend fun </*0*/ V> await(/*0*/ f: () -> V, /*1*/ machine: kotlin.coroutines.Continuation<V>): kotlin.Unit
|
||||
public final suspend fun </*0*/ V> await(/*0*/ f: kotlin.Int, /*1*/ machine: kotlin.coroutines.Continuation<V>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final suspend fun noParams(/*0*/ c: kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Unit
|
||||
public final suspend fun severalParams(/*0*/ x: kotlin.String, /*1*/ y: kotlin.Int, /*2*/ machine: kotlin.coroutines.Continuation<kotlin.Double>): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final suspend fun yieldString(/*0*/ value: kotlin.String, /*1*/ c: kotlin.coroutines.Continuation<kotlin.Unit>): kotlin.Unit
|
||||
}
|
||||
Reference in New Issue
Block a user