Fix tests after new Continuation API support
#KT-24863 Fixed
This commit is contained in:
+10
-8
@@ -1,11 +1,13 @@
|
||||
// !API_VERSION: 1.3
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// COMMON_COROUTINES_TEST
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
// LANGUAGE_VERSION: 1.3
|
||||
// SKIP_TXT
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class Controller {
|
||||
suspend fun noParams(): Unit = suspendCoroutineOrReturn {
|
||||
<!EXPERIMENTAL_FEATURE_WARNING!>suspend<!> fun noParams(): Unit = suspendCoroutineOrReturn {
|
||||
if (hashCode() % 2 == 0) {
|
||||
it.resume(Unit)
|
||||
COROUTINE_SUSPENDED
|
||||
@@ -14,10 +16,10 @@ class Controller {
|
||||
Unit
|
||||
}
|
||||
}
|
||||
suspend fun yieldString(value: String) = suspendCoroutineOrReturn<Int> {
|
||||
<!EXPERIMENTAL_FEATURE_WARNING!>suspend<!> fun yieldString(value: String) = suspendCoroutineOrReturn<Int> {
|
||||
it.resume(1)
|
||||
it checkType { _<Continuation<Int>>() }
|
||||
it.resume(<!TYPE_MISMATCH!>""<!>)
|
||||
it.<!TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>resume<!>("")
|
||||
|
||||
// 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
|
||||
@@ -25,10 +27,10 @@ class Controller {
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend Controller.() -> Unit) {}
|
||||
fun builder(c: <!EXPERIMENTAL_FEATURE_WARNING!>suspend<!> Controller.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
builder {
|
||||
<!EXPERIMENTAL_FEATURE_WARNING!>builder<!> {
|
||||
noParams() checkType { _<Unit>() }
|
||||
yieldString("abc") checkType { _<Int>() }
|
||||
}
|
||||
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package
|
||||
|
||||
public fun builder(/*0*/ c: suspend Controller.() -> kotlin.Unit): kotlin.Unit
|
||||
public fun test(): kotlin.Unit
|
||||
|
||||
public final class Controller {
|
||||
public constructor Controller()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final suspend fun noParams(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
public final suspend fun yieldString(/*0*/ value: kotlin.String): kotlin.Int
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// !CHECK_TYPE
|
||||
// SKIP_TXT
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
class Controller {
|
||||
suspend fun noParams(): Unit = suspendCoroutineOrReturn {
|
||||
if (hashCode() % 2 == 0) {
|
||||
it.resume(Unit)
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
else {
|
||||
Unit
|
||||
}
|
||||
}
|
||||
suspend fun yieldString(value: String) = suspendCoroutineOrReturn<Int> {
|
||||
it.resume(1)
|
||||
it checkType { _<Continuation<Int>>() }
|
||||
it.resume(<!TYPE_MISMATCH!>""<!>)
|
||||
|
||||
// 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"
|
||||
}
|
||||
}
|
||||
|
||||
fun builder(c: suspend Controller.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
builder {
|
||||
noParams() checkType { _<Unit>() }
|
||||
yieldString("abc") checkType { _<Int>() }
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,11 @@
|
||||
// COMMON_COROUTINES_TEST
|
||||
// SKIP_TXT
|
||||
import COROUTINES_PACKAGE.*
|
||||
|
||||
fun <T> foo(): Continuation<T> = null!!
|
||||
|
||||
fun bar() {
|
||||
suspend {
|
||||
println()
|
||||
}.startCoroutine(object: Continuation<Unit> {
|
||||
override val context: CoroutineContext
|
||||
get() = TODO("not implemented")
|
||||
|
||||
override fun resume(value: Unit) {
|
||||
TODO("not implemented")
|
||||
}
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
TODO("not implemented")
|
||||
}
|
||||
})
|
||||
}.startCoroutine(foo<Unit>())
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
package
|
||||
|
||||
public fun bar(): kotlin.Unit
|
||||
Reference in New Issue
Block a user