21 lines
467 B
Kotlin
Vendored
21 lines
467 B
Kotlin
Vendored
// IGNORE_BACKEND_FIR: JVM_IR
|
|
|
|
sealed class Result {
|
|
class Failure(val exception: Exception) : Result()
|
|
class Success(val message: String) : Result()
|
|
}
|
|
|
|
fun box(): String {
|
|
var result: Result
|
|
try {
|
|
result = Result.Success("OK")
|
|
}
|
|
catch (e: Exception) {
|
|
result = Result.Failure(Exception())
|
|
}
|
|
|
|
when (result) {
|
|
is Result.Failure -> throw result.exception
|
|
is Result.Success -> return result.message
|
|
}
|
|
} |