Support non-tail suspend calls in front-end
#KT-15597 In Progress
This commit is contained in:
@@ -5,15 +5,15 @@ import kotlin.coroutines.intrinsics.*
|
||||
fun nonSuspend() {}
|
||||
|
||||
suspend fun foo() {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
suspendCoroutineOrReturn { x: Continuation<Int> -> }
|
||||
|
||||
nonSuspend()
|
||||
}
|
||||
|
||||
suspend fun unitSuspend() {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
suspendCoroutineOrReturn { x: Continuation<Int> -> }
|
||||
}
|
||||
|
||||
suspend fun baz(): Int = run {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
suspendCoroutineOrReturn { x: Continuation<Int> -> }
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ suspend fun unit() {}
|
||||
|
||||
suspend fun foo() {
|
||||
suspend fun bar() {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE, SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!>
|
||||
baz()
|
||||
return unit()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun suspendLogAndThrow(exception: Throwable): Nothing = <!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { c ->
|
||||
suspend fun suspendLogAndThrow(exception: Throwable): Nothing = suspendCoroutineOrReturn { c ->
|
||||
c.resumeWithException(exception)
|
||||
SUSPENDED_MARKER
|
||||
}<!>
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
suspend fun unit1() {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>unit1()<!>
|
||||
unit1()
|
||||
}
|
||||
|
||||
suspend fun unit2() {
|
||||
@@ -13,6 +13,6 @@ suspend fun int1(): Int {
|
||||
suspend fun int2(): Int = int2()
|
||||
|
||||
suspend fun int3(): Int {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>int3()<!>
|
||||
int3()
|
||||
return int3()
|
||||
}
|
||||
|
||||
@@ -8,15 +8,15 @@ suspend fun baz(): Int = 1
|
||||
|
||||
suspend fun tryCatch(): Int {
|
||||
return try {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
suspendCoroutineOrReturn { x: Continuation<Int> -> }
|
||||
} catch (e: Exception) {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!> // another suspend function
|
||||
baz() // another suspend function
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun tryFinally(): Int {
|
||||
return try {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
suspendCoroutineOrReturn { x: Continuation<Int> -> }
|
||||
} finally {
|
||||
nonSuspend()
|
||||
}
|
||||
@@ -26,16 +26,16 @@ suspend fun returnInFinally(): Int {
|
||||
try {
|
||||
} finally {
|
||||
// Probably this is too restrictive, but it does not matter much
|
||||
return <!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE, SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!>
|
||||
return baz()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun tryCatchFinally(): Int {
|
||||
return try {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
suspendCoroutineOrReturn { x: Continuation<Int> -> }
|
||||
} catch (e: Exception) {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!> // another suspend function
|
||||
baz() // another suspend function
|
||||
} finally {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE, SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!>
|
||||
baz()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user