Add diagnostics tests. Forbid callable reference to coroutineContext
#KT-16908: Fixed
This commit is contained in:
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: test.kt
|
||||
// We cannot use COMMON_COROUTINES_TEST here due to !LANGUAGE directive
|
||||
// TODO: Fix this
|
||||
|
||||
inline fun go(f: () -> String) = f()
|
||||
|
||||
// FILE: box.kt
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object: Continuation<Unit> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
override fun resume(value: Unit) {
|
||||
}
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
throw exception
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
suspend fun String.id(): String = this
|
||||
|
||||
fun box(): String {
|
||||
val x = "OK"
|
||||
var res = "FAIL"
|
||||
builder {
|
||||
res = go(x::id)
|
||||
}
|
||||
return res
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: test.kt
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
inline suspend fun foo(x: suspend () -> String) = x()
|
||||
|
||||
// FILE: box.kt
|
||||
// WITH_RUNTIME
|
||||
// COMMON_COROUTINES_TEST
|
||||
|
||||
import COROUTINES_PACKAGE.*
|
||||
import COROUTINES_PACKAGE.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object: Continuation<Unit> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
override fun resume(value: Unit) {
|
||||
}
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
throw exception
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
suspend fun String.id() = this
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
builder {
|
||||
res = foo("OK"::id)
|
||||
}
|
||||
return res
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// IGNORE_BACKEND: JS, JS_IR
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: test.kt
|
||||
|
||||
inline suspend fun go(f: () -> String) = f()
|
||||
|
||||
// FILE: box.kt
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.experimental.*
|
||||
import kotlin.coroutines.experimental.intrinsics.*
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object: Continuation<Unit> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
override fun resume(value: Unit) {
|
||||
}
|
||||
|
||||
override fun resumeWithException(exception: Throwable) {
|
||||
throw exception
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
suspend fun String.id(): String = this
|
||||
|
||||
fun box(): String {
|
||||
val x = "OK"
|
||||
var res = "FAIL"
|
||||
builder {
|
||||
res = go(x::id)
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in New Issue
Block a user