Suspend lambdas can't have value parameters (UNSUPPORTED in M04).
This commit is contained in:
committed by
Stanislav Erokhin
parent
c5aeaae8e6
commit
f19581dc4d
@@ -220,6 +220,9 @@ class TypeResolver(
|
|||||||
val receiverTypeRef = type.receiverTypeReference
|
val receiverTypeRef = type.receiverTypeReference
|
||||||
val receiverType = if (receiverTypeRef == null) null else resolveType(c.noBareTypes(), receiverTypeRef)
|
val receiverType = if (receiverTypeRef == null) null else resolveType(c.noBareTypes(), receiverTypeRef)
|
||||||
|
|
||||||
|
if (hasSuspendModifier && type.parameters.isNotEmpty()) {
|
||||||
|
c.trace.report(UNSUPPORTED.on(type, "suspend function type with value parameters"))
|
||||||
|
}
|
||||||
val parameterDescriptors = resolveParametersOfFunctionType(type.parameters)
|
val parameterDescriptors = resolveParametersOfFunctionType(type.parameters)
|
||||||
|
|
||||||
val returnTypeRef = type.returnTypeReference
|
val returnTypeRef = type.returnTypeReference
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class GenericController<T> {
|
|||||||
suspend fun yield(t: T) {}
|
suspend fun yield(t: T) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <S, P1, P2, R> generate(p1: P1, p2: List<P2>, g: suspend GenericController<S>.(P1, P2) -> R): Four<S, P1, P2, R> = TODO()
|
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()
|
||||||
|
|
||||||
val test1 = generate(1, listOf("")) { p1, p2 ->
|
val test1 = generate(1, listOf("")) { p1, p2 ->
|
||||||
yield(p1)
|
yield(p1)
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@ class GenericController<T> {
|
|||||||
suspend fun yield(t: T) {}
|
suspend fun yield(t: T) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <S> generate(g: suspend GenericController<S>.(S) -> Unit): S = TODO()
|
fun <S> generate(g: suspend <!UNSUPPORTED!>GenericController<S>.(S) -> Unit<!>): S = TODO()
|
||||||
|
|
||||||
val test1 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
|
val test1 = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>generate<!> {
|
||||||
yield(4)
|
yield(4)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ fun <T> manyArgumentsBuilder(
|
|||||||
c3: suspend () -> Int
|
c3: suspend () -> Int
|
||||||
):T = null!!
|
):T = null!!
|
||||||
|
|
||||||
fun severalParamsInLambda(c: suspend (String, Int) -> Unit) {}
|
fun severalParamsInLambda(c: suspend <!UNSUPPORTED!>(String, Int) -> Unit<!>) {}
|
||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
builder({ 1 })
|
builder({ 1 })
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
fun <T> withS(x: T, sfn: suspend (T) -> Unit) = x
|
fun <T> withS(x: T, sfn: suspend <!UNSUPPORTED!>(T) -> Unit<!>) = x
|
||||||
|
|
||||||
val test1 = withS(100) {}
|
val test1 = withS(100) {}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
fun <T1, T2> withS2(x: T1, sfn1: suspend (T1) -> T2, sfn2: suspend (T2) -> Unit): T2 = null!!
|
fun <T1, T2> withS2(x: T1, sfn1: suspend <!UNSUPPORTED!>(T1) -> T2<!>, sfn2: suspend <!UNSUPPORTED!>(T2) -> Unit<!>): T2 = null!!
|
||||||
|
|
||||||
val test1 = withS2(100, { it.toLong().toString() }, { it.length })
|
val test1 = withS2(100, { it.toLong().toString() }, { it.length })
|
||||||
Vendored
+1
-1
@@ -2,5 +2,5 @@ typealias SuspendFn = suspend () -> Unit
|
|||||||
|
|
||||||
val test1: suspend () -> Unit = {}
|
val test1: suspend () -> Unit = {}
|
||||||
val test2: suspend Any.() -> Unit = {}
|
val test2: suspend Any.() -> Unit = {}
|
||||||
val test3: suspend Any.(Int) -> Int = { k: Int -> k + 1 }
|
val test3: suspend <!UNSUPPORTED!>Any.(Int) -> Int<!> = { k: Int -> k + 1 }
|
||||||
val test4: SuspendFn = {}
|
val test4: SuspendFn = {}
|
||||||
Vendored
+4
-4
@@ -5,14 +5,14 @@ interface SAM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typealias Test1 = suspend () -> Unit
|
typealias Test1 = suspend () -> Unit
|
||||||
typealias Test2 = suspend Int.(String) -> Unit
|
typealias Test2 = suspend Int.() -> Unit
|
||||||
typealias Test3 = <!WRONG_MODIFIER_TARGET!>suspend<!> Function0<Unit>
|
typealias Test3 = <!WRONG_MODIFIER_TARGET!>suspend<!> Function0<Unit>
|
||||||
typealias Test4 = <!WRONG_MODIFIER_TARGET!>suspend<!> Action
|
typealias Test4 = <!WRONG_MODIFIER_TARGET!>suspend<!> Action
|
||||||
typealias Test5 = List<suspend () -> Unit>
|
typealias Test5 = List<suspend () -> Unit>
|
||||||
typealias Test6 = <!WRONG_MODIFIER_TARGET!>suspend<!> List<() -> Unit>
|
typealias Test6 = <!WRONG_MODIFIER_TARGET!>suspend<!> List<() -> Unit>
|
||||||
typealias Test7 = <!WRONG_MODIFIER_TARGET!>suspend<!> SAM
|
typealias Test7 = <!WRONG_MODIFIER_TARGET!>suspend<!> SAM
|
||||||
typealias Test8 = <!WRONG_MODIFIER_TARGET!>suspend<!> <!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
|
typealias Test8 = <!WRONG_MODIFIER_TARGET!>suspend<!> <!UNRESOLVED_REFERENCE!>SuspendFunction0<!><Unit>
|
||||||
typealias Test9 = suspend (() -> Unit) -> Unit
|
typealias Test9 = suspend <!UNSUPPORTED!>(() -> Unit) -> Unit<!>
|
||||||
typealias Test10 = suspend (suspend () -> Unit) -> Unit
|
typealias Test10 = suspend <!UNSUPPORTED!>(suspend () -> Unit) -> Unit<!>
|
||||||
typealias Test11 = suspend () -> (suspend () -> Unit)
|
typealias Test11 = suspend () -> (suspend () -> Unit)
|
||||||
typealias Test12 = suspend (suspend (() -> Unit)) -> Unit
|
typealias Test12 = suspend <!UNSUPPORTED!>(suspend (() -> Unit)) -> Unit<!>
|
||||||
Vendored
+1
-1
@@ -11,7 +11,7 @@ public typealias Test1 = suspend () -> kotlin.Unit
|
|||||||
public typealias Test10 = suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
public typealias Test10 = suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
||||||
public typealias Test11 = suspend () -> suspend () -> kotlin.Unit
|
public typealias Test11 = suspend () -> suspend () -> kotlin.Unit
|
||||||
public typealias Test12 = suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
public typealias Test12 = suspend (suspend () -> kotlin.Unit) -> kotlin.Unit
|
||||||
public typealias Test2 = suspend kotlin.Int.(kotlin.String) -> kotlin.Unit
|
public typealias Test2 = suspend kotlin.Int.() -> kotlin.Unit
|
||||||
public typealias Test3 = () -> kotlin.Unit
|
public typealias Test3 = () -> kotlin.Unit
|
||||||
public typealias Test4 = Action
|
public typealias Test4 = Action
|
||||||
public typealias Test5 = kotlin.collections.List<suspend () -> kotlin.Unit>
|
public typealias Test5 = kotlin.collections.List<suspend () -> kotlin.Unit>
|
||||||
|
|||||||
+4
@@ -0,0 +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<!>>
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public typealias Test1 = suspend (kotlin.Int) -> kotlin.Unit
|
||||||
|
public typealias Test2 = suspend kotlin.Int.(kotlin.Int) -> kotlin.Unit
|
||||||
|
public typealias Test3 = kotlin.collections.List<suspend (kotlin.Int) -> kotlin.Unit>
|
||||||
|
public typealias Test4 = kotlin.collections.List<suspend kotlin.Int.(kotlin.Int) -> kotlin.Unit>
|
||||||
@@ -4518,6 +4518,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noValueParameters.kt")
|
||||||
|
public void testNoValueParameters() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionType/noValueParameters.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("suspendFunctionNIsUnresolved.kt")
|
@TestMetadata("suspendFunctionNIsUnresolved.kt")
|
||||||
public void testSuspendFunctionNIsUnresolved() throws Exception {
|
public void testSuspendFunctionNIsUnresolved() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionType/suspendFunctionNIsUnresolved.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/coroutines/suspendFunctionType/suspendFunctionNIsUnresolved.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user