Files
kotlin-fork/compiler/testData/codegen/box/properties/lateinit/accessorException.kt
T
2020-11-09 16:04:43 +03:00

35 lines
791 B
Kotlin
Vendored

// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: EXCEPTIONS_NOT_IMPLEMENTED
public class A {
fun getFromClass(): Boolean {
try {
val a = str
return false
} catch (e: RuntimeException) {
return true
}
}
fun getFromCompanion() = Companion.getFromCompanion()
private companion object {
private lateinit var str: String
fun getFromCompanion(): Boolean {
try {
val a = str
return false
} catch (e: RuntimeException) {
return true
}
}
}
}
fun box(): String {
if (!A().getFromClass()) return "Fail getFromClass"
if (!A().getFromCompanion()) return "Fail getFromCompanion"
return "OK"
}