Files
kotlin-fork/compiler/testData/codegen/box/topLevelInitializtion/failInInitializer4.kt
T
Alexander Shabalin aea8bac7d2 [K/N] Do not compile for deprecated targets and legacy MM
^KT-56533
^KT-58853
2023-05-30 16:44:58 +00:00

32 lines
613 B
Kotlin
Vendored

// TARGET_BACKEND: NATIVE
// FILE: lib.kt
import kotlin.native.concurrent.*
@ThreadLocal
val x: String = computeX()
fun computeX(): String = error("1")
@ThreadLocal
val y: String = computeY()
fun computeY(): String = "2"
// FILE: main.kt
fun box() : String {
try {
x
return "FAIL 1"
} catch(t: Error) {
val cause = t.cause
if (cause !is IllegalStateException) return "FAIL 2"
if (cause.message != "1") return "FAIL 3"
}
try {
y
return "FAIL 4"
} catch(t: Error) {
if (t.cause != null) return "FAIL 5"
}
return "OK"
}