Files
kotlin-fork/compiler/testData/codegen/box/jvm8/kt29242.kt
T
Mikhail Glukhikh 53ad502d2a [FIR2IR] Generate fake overrides earlier and bind them later
Before this commit, we generated fake overrides at last FIR2IR stage,
after having all functions and classes built. This could lead to a
situation when fake override was called before it was generated.
This commit fixes this situation.
2020-08-25 10:00:26 +03:00

24 lines
584 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// See also kt33054.kt
fun causesVerifyErrorSample(): Sample<Boolean> = Sample
.Success(true)
.flatMap { Sample.Failure(RuntimeException()) }
sealed class Sample<out T> {
inline fun <R> flatMap(f: (T) -> Sample<R>): Sample<R> =
when (this) {
is Failure -> this
is Success -> f(this.value)
}
data class Failure(val exception: Throwable): Sample<Nothing>()
data class Success<out T>(val value: T): Sample<T>()
}
fun box(): String {
causesVerifyErrorSample()
return "OK"
}