mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-10 15:53:46 +00:00
Use `// !LANGUAGE: -ReleaseCoroutines` instead in tests which require old (1.2) coroutines, and nothing in tests which require new coroutines because master is already 1.3. Also remove superfluous API_VERSION and other directives which have no effect anymore. Do not include runtime automatically with `WITH_COROUTINES`/`COMMON_COROUTINES_TEST` in box tests; require `WITH_RUNTIME` for that (majority of tests already had it anyway), but remove it from bytecode text tests where runtime is always added automatically. Fix the coroutine package selection code in KotlinTestUtils and update the bunch files correspondingly. Disable tests in `box/coroutines/noStdLib` on JVM: despite the name, these tests were launched with stdlib because of the code in CodegenTestCase, and they do not work without it because at least CoroutineUtil.kt requires stdlib to compile correctly
49 lines
1.2 KiB
Kotlin
Vendored
49 lines
1.2 KiB
Kotlin
Vendored
// WITH_COROUTINES
|
|
|
|
import helpers.*
|
|
// TREAT_AS_ONE_FILE
|
|
import kotlin.coroutines.*
|
|
import kotlin.coroutines.intrinsics.*
|
|
suspend fun suspendHere(): String = suspendCoroutineUninterceptedOrReturn { x ->
|
|
x.resume("OK")
|
|
}
|
|
|
|
fun builder(c: suspend () -> Unit) {
|
|
c.startCoroutine(EmptyContinuation)
|
|
}
|
|
|
|
val nonConstOne = 1
|
|
|
|
fun box(): String {
|
|
var result = "fail 1"
|
|
builder {
|
|
// Initialize var with Int value
|
|
for (i in 1..nonConstOne) {
|
|
if ("".length > 0) continue
|
|
}
|
|
|
|
// This variable should take the same slot as 'i' had
|
|
var s: String
|
|
|
|
// We should not spill 's' to continuation field because it's not initialized
|
|
// More precisely it contains a value of wrong type (it conflicts with contents of local var table),
|
|
// so an attempt of spilling may lead to problems on Android
|
|
if (suspendHere() == "OK") {
|
|
s = "OK"
|
|
}
|
|
else {
|
|
s = "fail 2"
|
|
}
|
|
|
|
result = s
|
|
}
|
|
|
|
return result
|
|
}
|
|
|
|
// 1 LOCALVARIABLE i I L.* 2
|
|
// 1 LOCALVARIABLE s Ljava/lang/String; L.* 2
|
|
// 0 PUTFIELD VarValueConflictsWithTableKt\$box\$1.I\$0 : I
|
|
/* 2 loads in cycle */
|
|
// 2 ILOAD 2
|