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.
19 lines
1.4 KiB
Plaintext
Vendored
19 lines
1.4 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
|
|
ERROR_CALL 'Unresolved reference: <Inapplicable(INAPPLICABLE): [test/foo]>#' type=IrErrorType
|
|
FUNCTION_REFERENCE 'public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test' type=kotlin.reflect.KFunction1<kotlin.IntArray, kotlin.String> origin=null reflectionTarget=<same>
|
|
$receiver: CONST String type=kotlin.String value="Fail"
|