JVM_IR: Do not unbox Result parameter if it not only one inline class
parameter, since in this case, the compiler generates a bridge, where the result is unboxed.
This commit is contained in:
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: SAM_CONVERSIONS
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class IC(val value: Any)
|
||||
|
||||
fun <T> foo(a: Result<T>, ic: IC): Pair<T, Any> = bar(a, ic) { a, ic ->
|
||||
a.getOrThrow() to ic.value
|
||||
}
|
||||
|
||||
fun interface FunIFace<T1, T2, R> {
|
||||
fun call(t1: T1, t2: T2): R
|
||||
}
|
||||
|
||||
fun <T1, T2, R> bar(t1: T1, t2: T2, f: FunIFace<T1, T2, R>): R {
|
||||
return f.call(t1, t2)
|
||||
}
|
||||
|
||||
fun Pair<Any, Any>.join(): String = "$first$second"
|
||||
|
||||
fun box(): String = foo<Any>(Result.success("O"), IC("K")).join()
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class IC(val value: Any)
|
||||
|
||||
fun <T> foo(a: Result<T>, ic: IC): Pair<T, Any> = bar(a, ic) { a, ic ->
|
||||
a.getOrThrow() to ic.value
|
||||
}
|
||||
|
||||
fun <T1, T2, R> bar(t1: T1, t2: T2, f: (T1, T2) -> R): R {
|
||||
return f(t1, t2)
|
||||
}
|
||||
|
||||
fun Pair<Any, Any>.join(): String = "$first$second"
|
||||
|
||||
fun box(): String = foo<Any>(Result.success("O"), IC("K")).join()
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +InlineClasses
|
||||
// WITH_RUNTIME
|
||||
|
||||
inline class IC(val value: Any)
|
||||
|
||||
fun <T> foo(a: Result<T>, ic: IC): Pair<T, Any> = bar(a, ic, object : IFace<Result<T>, IC, Pair<T, Any>> {
|
||||
override fun call(a: Result<T>, ic: IC): Pair<T, Any> = a.getOrThrow() to ic.value
|
||||
})
|
||||
|
||||
interface IFace<T1, T2, R> {
|
||||
fun call(t1: T1, t2: T2): R
|
||||
}
|
||||
|
||||
fun <T1, T2, R> bar(t1: T1, t2: T2, f: IFace<T1, T2, R>): R {
|
||||
return f.call(t1, t2)
|
||||
}
|
||||
|
||||
fun Pair<Any, Any>.join(): String = "$first$second"
|
||||
|
||||
fun box(): String = foo<Any>(Result.success("O"), IC("K")).join()
|
||||
Reference in New Issue
Block a user