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.
26 lines
2.1 KiB
Plaintext
Vendored
26 lines
2.1 KiB
Plaintext
Vendored
FILE fqName:test fileName:/boundInlineAdaptedReference.kt
|
|
FUN name:foo visibility:public modality:FINAL <> (x:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit [inline]
|
|
VALUE_PARAMETER name:x index:0 type:kotlin.Function0<kotlin.Unit>
|
|
BLOCK_BODY
|
|
FUN name:id visibility:public modality:FINAL <> ($receiver:kotlin.String, s:kotlin.String, xs:kotlin.IntArray) returnType:kotlin.String
|
|
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
|
|
VALUE_PARAMETER name:s index:0 type:kotlin.String
|
|
EXPRESSION_BODY
|
|
GET_VAR '<this>: kotlin.String declared in test.id' type=kotlin.String origin=null
|
|
VALUE_PARAMETER name:xs index:1 type:kotlin.IntArray varargElementType:kotlin.Int [vararg]
|
|
BLOCK_BODY
|
|
RETURN type=kotlin.Nothing from='public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test'
|
|
GET_VAR 's: kotlin.String declared in test.id' type=kotlin.String origin=null
|
|
FUN name:test visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
|
BLOCK_BODY
|
|
CALL 'public final fun foo (x: kotlin.Function0<kotlin.Unit>): kotlin.Unit [inline] declared in test' type=kotlin.Unit origin=null
|
|
x: BLOCK type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE
|
|
FUN ADAPTER_FOR_CALLABLE_REFERENCE name:id visibility:local modality:FINAL <> ($receiver:kotlin.String) returnType:kotlin.Unit
|
|
$receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:kotlin.String
|
|
BLOCK_BODY
|
|
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
|
CALL 'public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test' type=kotlin.String origin=null
|
|
$receiver: GET_VAR 'receiver: kotlin.String declared in test.test.id' type=kotlin.String origin=ADAPTED_FUNCTION_REFERENCE
|
|
FUNCTION_REFERENCE 'local final fun id (): kotlin.Unit declared in test.test' type=kotlin.Function0<kotlin.Unit> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null
|
|
$receiver: CONST String type=kotlin.String value="Fail"
|