Move coroutine intrinsics to kotlin.coroutine.intrinsics package
Also rename val SUSPENDED to SUSPENDED_MARKER #KT-15698 Fixed
This commit is contained in:
@@ -1,23 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class Controller {
|
||||
suspend fun noParams(): Unit = CoroutineIntrinsics.suspendCoroutineOrReturn {
|
||||
suspend fun noParams(): Unit = suspendCoroutineOrReturn {
|
||||
if (hashCode() % 2 == 0) {
|
||||
it.resume(Unit)
|
||||
CoroutineIntrinsics.SUSPENDED
|
||||
SUSPENDED_MARKER
|
||||
}
|
||||
else {
|
||||
Unit
|
||||
}
|
||||
}
|
||||
suspend fun yieldString(value: String) = CoroutineIntrinsics.suspendCoroutineOrReturn<Int> {
|
||||
suspend fun yieldString(value: String) = suspendCoroutineOrReturn<Int> {
|
||||
it.resume(1)
|
||||
it checkType { _<Continuation<Int>>() }
|
||||
it.resume(<!TYPE_MISMATCH!>""<!>)
|
||||
|
||||
// We can return anything here, 'CoroutineIntrinsics.suspendCoroutineOrReturn' is not very type-safe
|
||||
// We can return anything here, 'suspendCoroutineOrReturn' is not very type-safe
|
||||
// Also we can call resume and then return the value too, but it's still just our problem
|
||||
"Not-int"
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun nonSuspend() {}
|
||||
|
||||
suspend fun foo() {
|
||||
CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
|
||||
nonSuspend()
|
||||
}
|
||||
|
||||
suspend fun unitSuspend() {
|
||||
CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
}
|
||||
|
||||
suspend fun baz(): Int = run {
|
||||
CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
}
|
||||
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
// Tail calls are not allowed to be Nothing typed. See KT-15051
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun suspendLogAndThrow(exception: Throwable): Nothing = CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { c ->
|
||||
suspend fun suspendLogAndThrow(exception: Throwable): Nothing = <!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { c ->
|
||||
c.resumeWithException(exception)
|
||||
CoroutineIntrinsics.SUSPENDED
|
||||
SUSPENDED_MARKER
|
||||
}<!>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun nonSuspend() {}
|
||||
|
||||
@@ -7,7 +8,7 @@ suspend fun baz(): Int = 1
|
||||
|
||||
suspend fun tryCatch(): Int {
|
||||
return try {
|
||||
CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
} catch (e: Exception) {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!> // another suspend function
|
||||
}
|
||||
@@ -15,7 +16,7 @@ suspend fun tryCatch(): Int {
|
||||
|
||||
suspend fun tryFinally(): Int {
|
||||
return try {
|
||||
CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
} finally {
|
||||
nonSuspend()
|
||||
}
|
||||
@@ -31,7 +32,7 @@ suspend fun returnInFinally(): Int {
|
||||
|
||||
suspend fun tryCatchFinally(): Int {
|
||||
return try {
|
||||
CoroutineIntrinsics.<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>suspendCoroutineOrReturn { x: Continuation<Int> -> }<!>
|
||||
} catch (e: Exception) {
|
||||
<!SUSPENSION_CALL_MUST_BE_USED_AS_RETURN_VALUE!>baz()<!> // another suspend function
|
||||
} finally {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun baz() = 1
|
||||
|
||||
@@ -14,17 +15,17 @@ suspend fun bar1() {
|
||||
return if (1.hashCode() > 0) {
|
||||
foo()
|
||||
}
|
||||
else CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation<Unit> -> }
|
||||
else suspendCoroutineOrReturn { x: Continuation<Unit> -> }
|
||||
}
|
||||
|
||||
suspend fun bar2() =
|
||||
if (1.hashCode() > 0) {
|
||||
foo()
|
||||
}
|
||||
else CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation<Unit> -> }
|
||||
else suspendCoroutineOrReturn { x: Continuation<Unit> -> }
|
||||
|
||||
suspend fun bar3() =
|
||||
when {
|
||||
true -> { foo() }
|
||||
else -> CoroutineIntrinsics.suspendCoroutineOrReturn { x: Continuation<Unit> -> }
|
||||
else -> suspendCoroutineOrReturn { x: Continuation<Unit> -> }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user