Support common calls on suspend function typed values

Also support multiple value parameters in suspend function type

 #KT-15379 Fixed
 #KT-15380 Fixed
This commit is contained in:
Denis Zharkov
2016-12-21 14:15:46 +03:00
parent d0ba048342
commit 8475869fb3
29 changed files with 299 additions and 77 deletions
@@ -4,7 +4,7 @@ class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S, P1, P2, R> generate(p1: P1, p2: List<P2>, g: suspend <!UNSUPPORTED!>GenericController<S>.(P1, P2) -> R<!>): Four<S, P1, P2, R> = TODO()
fun <S, P1, P2, R> generate(p1: P1, p2: List<P2>, g: suspend GenericController<S>.(P1, P2) -> R): Four<S, P1, P2, R> = TODO()
val test1 = generate(1, listOf("")) { p1, p2 ->
yield(p1)
@@ -13,4 +13,4 @@ val test1 = generate(1, listOf("")) { p1, p2 ->
}
fun <X> listOf(vararg x: X): List<X> = TODO()
class Four<X, Y, Z, T>
class Four<X, Y, Z, T>
@@ -4,7 +4,7 @@ class GenericController<T> {
suspend fun yield(t: T) {}
}
fun <S> generate(g: suspend <!UNSUPPORTED!>GenericController<S>.(S) -> Unit<!>): S = TODO()
fun <S> generate(g: suspend GenericController<S>.(S) -> Unit): S = TODO()
val test1 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
yield(4)
@@ -12,7 +12,7 @@ fun <T> manyArgumentsBuilder(
c3: suspend () -> Int
):T = null!!
fun severalParamsInLambda(c: suspend <!UNSUPPORTED!>(String, Int) -> Unit<!>) {}
fun severalParamsInLambda(c: suspend (String, Int) -> Unit) {}
fun foo() {
builder({ 1 })
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun <T> withS(x: T, sfn: suspend <!UNSUPPORTED!>(T) -> Unit<!>) = x
fun <T> withS(x: T, sfn: suspend (T) -> Unit) = x
val test1 = withS(100) {}
fun <TT> test2(x: TT) = withS(x) {}
fun <TT> test2(x: TT) = withS(x) {}
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun <T1, T2> withS2(x: T1, sfn1: suspend <!UNSUPPORTED!>(T1) -> T2<!>, sfn2: suspend <!UNSUPPORTED!>(T2) -> Unit<!>): T2 = null!!
fun <T1, T2> withS2(x: T1, sfn1: suspend (T1) -> T2, sfn2: suspend (T2) -> Unit): T2 = null!!
val test1 = withS2(100, { it.toLong().toString() }, { it.length })
val test1 = withS2(100, { it.toLong().toString() }, { it.length })
@@ -0,0 +1,10 @@
suspend fun foo1(q: suspend () -> Unit) = q()
suspend fun foo2(x: suspend (Int) -> String) = x(1)
suspend fun foo3(y: suspend String.(Int) -> Double) = "".y(1)
suspend fun String.foo4(y: suspend String.(Int) -> Double) = "".y(1)
fun noSuspend(x: suspend (Int) -> String) {
<!ILLEGAL_SUSPEND_FUNCTION_CALL!>x<!>(1)
}
@@ -0,0 +1,7 @@
package
public suspend fun foo1(/*0*/ q: suspend () -> kotlin.Unit): kotlin.Unit
public suspend fun foo2(/*0*/ x: suspend (kotlin.Int) -> kotlin.String): kotlin.String
public suspend fun foo3(/*0*/ y: suspend kotlin.String.(kotlin.Int) -> kotlin.Double): kotlin.Double
public fun noSuspend(/*0*/ x: suspend (kotlin.Int) -> kotlin.String): kotlin.Unit
public suspend fun kotlin.String.foo4(/*0*/ y: suspend kotlin.String.(kotlin.Int) -> kotlin.Double): kotlin.Double
@@ -2,5 +2,5 @@ typealias SuspendFn = suspend () -> Unit
val test1: suspend () -> Unit = {}
val test2: suspend Any.() -> Unit = {}
val test3: suspend <!UNSUPPORTED!>Any.(Int) -> Int<!> = { k: Int -> k + 1 }
val test4: SuspendFn = {}
val test3: suspend Any.(Int) -> Int = { k: Int -> k + 1 }
val test4: SuspendFn = {}
@@ -12,7 +12,7 @@ typealias Test5 = List<suspend () -> Unit>
typealias Test6 = <!WRONG_MODIFIER_TARGET!>suspend<!> List<() -> Unit>
typealias Test7 = <!WRONG_MODIFIER_TARGET!>suspend<!> SAM
typealias Test8 = <!WRONG_MODIFIER_TARGET!>suspend<!> <!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
typealias Test9 = suspend <!UNSUPPORTED!>(() -> Unit) -> Unit<!>
typealias Test10 = suspend <!UNSUPPORTED!>(suspend () -> Unit) -> Unit<!>
typealias Test9 = suspend (() -> Unit) -> Unit
typealias Test10 = suspend (suspend () -> Unit) -> Unit
typealias Test11 = suspend () -> (suspend () -> Unit)
typealias Test12 = suspend <!UNSUPPORTED!>(suspend (() -> Unit)) -> Unit<!>
typealias Test12 = suspend (suspend (() -> Unit)) -> Unit
@@ -1,2 +1,2 @@
fun test1(sfn: suspend () -> Unit) = <!FUNCTION_EXPECTED!>sfn<!>()
fun test2(sfn: suspend () -> Unit) = sfn.<!UNRESOLVED_REFERENCE!>invoke<!>()
fun test1(sfn: suspend () -> Unit) = <!ILLEGAL_SUSPEND_FUNCTION_CALL!>sfn<!>()
fun test2(sfn: suspend () -> Unit) = sfn.<!ILLEGAL_SUSPEND_FUNCTION_CALL!>invoke<!>()
@@ -1,4 +1,4 @@
package
public fun test1(/*0*/ sfn: suspend () -> kotlin.Unit): [ERROR : Error function type]
public fun test2(/*0*/ sfn: suspend () -> kotlin.Unit): [ERROR : Error function type]
public fun test1(/*0*/ sfn: suspend () -> kotlin.Unit): kotlin.Unit
public fun test2(/*0*/ sfn: suspend () -> kotlin.Unit): kotlin.Unit
@@ -1,4 +1,4 @@
typealias Test1 = suspend <!UNSUPPORTED!>(Int) -> Unit<!>
typealias Test2 = suspend <!UNSUPPORTED!>Int.(Int) -> Unit<!>
typealias Test3 = List<suspend <!UNSUPPORTED!>(Int) -> Unit<!>>
typealias Test4 = List<suspend <!UNSUPPORTED!>Int.(Int) -> Unit<!>>
typealias Test1 = suspend (Int) -> Unit
typealias Test2 = suspend Int.(Int) -> Unit
typealias Test3 = List<suspend (Int) -> Unit>
typealias Test4 = List<suspend Int.(Int) -> Unit>