PSI2IR: Support suspend conversion for function references

This commit is contained in:
Dmitry Petrov
2020-04-23 14:25:08 +03:00
parent 10cda4b54f
commit 6b9a7464f5
8 changed files with 288 additions and 16 deletions
@@ -0,0 +1,33 @@
// !LANGUAGE: +SuspendConversion
fun useSuspend(fn: suspend () -> Unit) {}
fun useSuspendInt(fn: suspend (Int) -> Unit) {}
suspend fun foo0() {}
fun foo1() {}
fun fooInt(x: Int) {}
fun foo2(vararg xs: Int) {}
fun foo3(): Int = 42
fun foo4(i: Int = 42) {}
class C {
fun bar() {}
}
fun testLambda() { useSuspend { foo1() } }
fun testNoCoversion() { useSuspend(::foo0) }
fun testSuspendPlain() { useSuspend(::foo1) }
fun testSuspendWithArgs() { useSuspendInt(::fooInt) }
fun testWithVararg() { useSuspend(::foo2) }
fun testWithVarargMapped() { useSuspendInt(::foo2) }
fun testWithCoercionToUnit() { useSuspend(::foo3) }
fun testWithDefaults() { useSuspend(::foo4) }
fun testWithBoundReceiver() { useSuspend(C()::bar) }