025d1ca64d
This fixes the problem in JVM IR backend which didn't pass bound receiver value of an adapted function reference to the superclass (kotlin/jvm/internal/AdaptedFunctionReference), which caused equals to work incorrectly on such references (see changes in box tests). Previously, bound adapted function reference was represented as IrFunctionExpression to an adapter function which calls the callee. The value of the bound receiver in that case could only be found in the body of that adapter function. This is not very convenient, so this change makes psi2ir produce a block of the adapter function + reference to it. The bound receiver value is then found in the reference. This is basically similar to what ProvisionalFunctionExpressionLowering is doing for all function expressions. And since this IR structure is already supported in FunctionReferenceLowering, the problem in the JVM IR is fixed without any additional modifications. However, inliners do not support this IR structure yet, see KT-38535 and KT-38536.
11 lines
195 B
Kotlin
Vendored
11 lines
195 B
Kotlin
Vendored
// IGNORE_BACKEND_FIR: JVM_IR
|
|
|
|
inline fun foo(x: () -> Unit): String {
|
|
x()
|
|
return "OK"
|
|
}
|
|
|
|
fun String.id(s: String = this, vararg xs: Int): String = s
|
|
|
|
fun box(): String = foo("Fail"::id)
|