JVM_IR: box bound receiver before calling the reference constructor
This is needed for the inliner: since the information about Kotlin type of the bound receiver is nowhere in the output binary, the inliner will have no clue how to box inline class values. Moving the boxing outside the object means the inliner doesn't need to know about it; from its point of view, the captured value has type `Any`.
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_IR_AGAINST_OLD
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline class C(val x: String) {
|
||||
fun f() = x.toString()
|
||||
}
|
||||
|
||||
inline fun inlineFun(lambda: () -> String = C("OK")::f): String = lambda()
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String = inlineFun()
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_IR_AGAINST_OLD
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline class C(val x: Any?) {
|
||||
fun f() = x.toString()
|
||||
}
|
||||
|
||||
inline fun inlineFun(lambda: () -> String = C("OK")::f): String = lambda()
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String = inlineFun()
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// SKIP_INLINE_CHECK_IN: inlineFun$default
|
||||
// IGNORE_BACKEND: JVM
|
||||
// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_MULTI_MODULE_IR_AGAINST_OLD
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline class C(val x: Int) {
|
||||
fun f() = x.toString()
|
||||
}
|
||||
|
||||
inline fun inlineFun(lambda: () -> String = C(1)::f): String = lambda()
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val result = inlineFun()
|
||||
return if (result == "1") "OK" else result
|
||||
}
|
||||
Reference in New Issue
Block a user