Add diagnostics tests. Forbid callable reference to coroutineContext

#KT-16908: Fixed
This commit is contained in:
Ilmir Usmanov
2018-06-06 18:54:08 +03:00
parent f94b579d19
commit eea95441c5
107 changed files with 780 additions and 4849 deletions
@@ -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
}
@@ -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
}