[K/N] Make exception handling in initializers more consistent with jvm

^KT-57091
This commit is contained in:
Pavel Kunyavskiy
2023-03-03 17:54:48 +01:00
committed by Space Team
parent 0506d39d8a
commit dc2e072af2
29 changed files with 315 additions and 164 deletions
@@ -1,18 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// FILE: lib.kt
val x: String = computeX()
fun computeX(): String = error("zzz")
// FILE: main.kt
fun main() {
try {
println(x)
} catch(t: IllegalStateException) {
println("caught")
}
}
@@ -1,28 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// FILE: lib.kt
val x: String = computeX()
fun computeX(): String = error("zzz")
val y: String = computeY()
fun computeY(): String = "qzz"
// FILE: main.kt
@OptIn(ExperimentalStdlibApi::class)
fun main() {
try {
println(x)
} catch(t: IllegalStateException) {
println("caught")
}
try {
println(y)
} catch(t: kotlin.native.FileFailedToInitializeException) {
println("caught2")
}
}
@@ -1,2 +0,0 @@
caught
caught2
@@ -1,31 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// FILE: lib.kt
import kotlin.native.concurrent.*
@ThreadLocal
val x: String = computeX()
fun computeX(): String = error("zzz")
val y: String = computeY()
fun computeY(): String = "qzz"
// FILE: main.kt
@OptIn(ExperimentalStdlibApi::class)
fun main() {
try {
println(x)
} catch(t: IllegalStateException) {
println("caught")
}
try {
println(y)
} catch(t: kotlin.native.FileFailedToInitializeException) {
println("caught2")
}
}
@@ -1,2 +0,0 @@
caught
caught2
@@ -1,32 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
// FILE: lib.kt
import kotlin.native.concurrent.*
@ThreadLocal
val x: String = computeX()
fun computeX(): String = error("zzz")
@ThreadLocal
val y: String = computeY()
fun computeY(): String = "qzz"
// FILE: main.kt
@OptIn(ExperimentalStdlibApi::class)
fun main() {
try {
println(x)
} catch(t: IllegalStateException) {
println("caught")
}
try {
println(y)
} catch(t: kotlin.native.FileFailedToInitializeException) {
println("caught2")
}
}
@@ -1,2 +0,0 @@
caught
caught2