Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/callableReferences/kt37986.kt
T
Dmitry Petrov d5ace43614 KT-37986 Force boxing of inline class returned from function reference
KT-37998 Provide KotlinType for safe call
2020-04-04 01:32:45 +03:00

25 lines
400 B
Kotlin
Vendored

// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
inline class R(val x: Any)
fun useR(r: R) {
if (r.x as String != "OK") throw AssertionError("$r")
}
fun useR0(fn: () -> R) {
useR(fn())
}
fun useR1(r: R, fn: (R) -> R) {
useR(fn(r))
}
fun fnWithDefaultR(r: R = R("OK")) = r
fun box(): String {
useR0(::fnWithDefaultR)
useR1(R("OK"), ::fnWithDefaultR)
return "OK"
}