Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/kt45991.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

55 lines
1.1 KiB
Kotlin
Vendored

// WITH_STDLIB
// IGNORE_BACKEND: JVM
// IGNORE_LIGHT_ANALYSIS
var result = ""
fun ex1_(res: Result<Int>) {
res.fold(
onSuccess = { result += "Ex $it\n" },
onFailure = {},
)
}
fun ex1(res: Result<Int>) {
res.fold(
onSuccess = { ex1_(res) },
onFailure = { ex1_(Result.failure(it)) }
)
}
val ex2_: (Result<Int>) -> Unit = { res ->
res.fold(
onSuccess = { result += "Ex $it\n" },
onFailure = {},
)
}
val ex2: (Result<Int>) -> Unit = { res ->
res.fold(
onSuccess = { ex2_(Result.success(it)) },
onFailure = { ex2_(Result.failure(it)) }
)
}
val ex3_: (Result<Int>) -> Unit = { res ->
res.fold(
onSuccess = { result += "Ex $it\n" },
onFailure = {},
)
}
val ex3: (Result<Int>) -> Unit = { res ->
res.fold(
onSuccess = { ex3_(res) },
onFailure = { ex3_(Result.failure(it)) }
)
}
fun box(): String {
ex1(Result.success(1))
ex2(Result.success(2))
ex3(Result.success(3))
return if (result == "Ex 1\nEx 2\nEx 3\n") "OK" else "FAIL $result"
}