diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 47704b7d1e1..3bdbf207cff 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -2025,6 +2025,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/emptyVarargAndDefault.kt"); } + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt"); + } + @TestMetadata("inlineDefault.kt") public void testInlineDefault() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineDefault.kt"); diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java index 55e5413c3af..1d9ff0887f1 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1404,6 +1404,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @TestMetadata("boundInlineAdaptedReference.kt") + public void testBoundInlineAdaptedReference() throws Exception { + runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt"); + } + @TestMetadata("boundInnerGenericConstructor.kt") public void testBoundInnerGenericConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.kt"); diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt index 154cf320c64..28381f9040f 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ReflectionReferencesGenerator.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.builtins.createFunctionType import org.jetbrains.kotlin.builtins.isKFunctionType import org.jetbrains.kotlin.builtins.isKSuspendFunctionType import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl @@ -31,9 +32,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol -import org.jetbrains.kotlin.ir.types.IrSimpleType -import org.jetbrains.kotlin.ir.types.defaultType -import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl import org.jetbrains.kotlin.ir.util.referenceClassifier import org.jetbrains.kotlin.ir.util.referenceFunction import org.jetbrains.kotlin.ir.util.withScope @@ -44,6 +42,7 @@ import org.jetbrains.kotlin.psi.psiUtil.startOffsetSkippingComments import org.jetbrains.kotlin.psi2ir.intermediate.CallBuilder import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.model.* +import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue import org.jetbrains.kotlin.resolve.scopes.receivers.TransientReceiver import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.expressions.DoubleColonLHS @@ -110,7 +109,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St private fun generateAdaptedCallableReference( ktCallableReference: KtCallableReferenceExpression, callBuilder: CallBuilder - ): IrExpressionBase { + ): IrExpression { val adapteeDescriptor = callBuilder.descriptor if (adapteeDescriptor !is FunctionDescriptor) { throw AssertionError("Function descriptor expected in adapted callable reference: $adapteeDescriptor") @@ -128,9 +127,9 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St val ktExpectedReturnType = ktFunctionalTypeArguments.last().type val ktExpectedParameterTypes = ktFunctionalTypeArguments.take(ktFunctionalTypeArguments.size - 1).map { it.type } - val irAdapterFun = createAdapterFun(startOffset, endOffset, adapteeDescriptor, ktExpectedParameterTypes, ktExpectedReturnType) - val adapteeCall = createAdapteeCall(startOffset, endOffset, ktCallableReference, adapteeSymbol, callBuilder, irAdapterFun) - val irCall = adapteeCall.callExpression + val irAdapterFun = + createAdapterFun(startOffset, endOffset, adapteeDescriptor, ktExpectedParameterTypes, ktExpectedReturnType, callBuilder) + val irCall = createAdapteeCall(startOffset, endOffset, adapteeSymbol, callBuilder, irAdapterFun) irAdapterFun.body = IrBlockBodyImpl(startOffset, endOffset).apply { if (KotlinBuiltIns.isUnit(ktExpectedReturnType)) @@ -139,96 +138,91 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St statements.add(IrReturnImpl(startOffset, endOffset, context.irBuiltIns.nothingType, irAdapterFun.symbol, irCall)) } - val irFunExpr = IrFunctionExpressionImpl( - startOffset, endOffset, - irFunctionalType, - irAdapterFun, - IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE - ) - - return if (adapteeCall.tmpReceivers.isEmpty()) { - irFunExpr - } else { - IrBlockImpl( - startOffset, endOffset, irFunctionalType, - origin = null, - statements = adapteeCall.tmpReceivers + irFunExpr + val resolvedCall = callBuilder.original + return statementGenerator.generateCallReceiver( + ktCallableReference, + resolvedCall.resultingDescriptor, + resolvedCall.dispatchReceiver, resolvedCall.extensionReceiver, + isSafe = false + ).call { dispatchReceiverValue, extensionReceiverValue -> + val irAdapterRef = IrFunctionReferenceImpl( + startOffset, endOffset, irFunctionalType, irAdapterFun.symbol, irAdapterFun.typeParameters.size, + irAdapterFun.valueParameters.size, null, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE ) + + val irDispatchReceiver = dispatchReceiverValue?.loadIfExists() + val irExtensionReceiver = extensionReceiverValue?.loadIfExists() + check(irDispatchReceiver == null || irExtensionReceiver == null) { + "Bound callable reference cannot have both receivers: $adapteeDescriptor" + } + val receiver = irDispatchReceiver ?: irExtensionReceiver + + if (receiver == null) { + IrFunctionExpressionImpl( + startOffset, endOffset, irFunctionalType, irAdapterFun, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE + ) + } else { + val statements = SmartList() + if (receiver.isSafeToUseWithoutCopying()) { + irAdapterRef.extensionReceiver = receiver + } else { + val irVariable = statementGenerator.scope.createTemporaryVariable(receiver, "receiver") + irAdapterRef.extensionReceiver = IrGetValueImpl(startOffset, endOffset, irVariable.symbol) + statements.add(irVariable) + } + statements.add(irAdapterFun) + statements.add(irAdapterRef) + + IrBlockImpl(startOffset, endOffset, irFunctionalType, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE, statements) + } } } - private class AdapteeCall( - val callExpression: IrExpression, - val tmpReceivers: List - ) - private fun createAdapteeCall( startOffset: Int, endOffset: Int, - ktCallableReference: KtCallableReferenceExpression, adapteeSymbol: IrFunctionSymbol, callBuilder: CallBuilder, irAdapterFun: IrSimpleFunction - ): AdapteeCall { + ): IrExpression { val resolvedCall = callBuilder.original val resolvedDescriptor = resolvedCall.resultingDescriptor - val tmpReceivers = SmartList() + val irType = resolvedDescriptor.returnType!!.toIrType() - val irCall = statementGenerator.generateCallReceiver( - ktCallableReference, - resolvedDescriptor, - resolvedCall.dispatchReceiver, resolvedCall.extensionReceiver, - isSafe = false - ).call { dispatchReceiverValue, extensionReceiverValue -> - val irType = resolvedDescriptor.returnType!!.toIrType() + val irCall = + if (resolvedDescriptor is ConstructorDescriptor) + IrConstructorCallImpl.fromSymbolDescriptor( + startOffset, endOffset, irType, + adapteeSymbol as IrConstructorSymbol + ) + else + IrCallImpl( + startOffset, endOffset, irType, + adapteeSymbol, + origin = null, superQualifierSymbol = null + ) - val irAdapteeCallInner = - if (resolvedDescriptor is ConstructorDescriptor) - IrConstructorCallImpl.fromSymbolDescriptor( - startOffset, endOffset, irType, - adapteeSymbol as IrConstructorSymbol - ) - else - IrCallImpl( - startOffset, endOffset, irType, - adapteeSymbol, - origin = null, superQualifierSymbol = null - ) - - context.callToSubstitutedDescriptorMap[irAdapteeCallInner] = resolvedDescriptor - - val irDispatchReceiver = dispatchReceiverValue?.loadIfExists() - val irExtensionReceiver = extensionReceiverValue?.loadIfExists() - - if (irDispatchReceiver != null) { - if (irDispatchReceiver.isSafeToUseWithoutCopying()) { - irAdapteeCallInner.dispatchReceiver = irDispatchReceiver - } else { - val irVariable = statementGenerator.scope.createTemporaryVariable(irDispatchReceiver, "this") - irAdapteeCallInner.dispatchReceiver = IrGetValueImpl(startOffset, endOffset, irVariable.symbol) - tmpReceivers.add(irVariable) - } + val hasBoundDispatchReceiver = resolvedCall.dispatchReceiver != null && resolvedCall.dispatchReceiver !is TransientReceiver + val hasBoundExtensionReceiver = resolvedCall.extensionReceiver != null && resolvedCall.extensionReceiver !is TransientReceiver + if (hasBoundDispatchReceiver || hasBoundExtensionReceiver) { + // In case of a bound reference, the receiver (which can only be one) is passed in the extension receiver parameter. + val receiverValue = IrGetValueImpl( + startOffset, endOffset, irAdapterFun.extensionReceiverParameter!!.symbol, IrStatementOrigin.ADAPTED_FUNCTION_REFERENCE + ) + when { + hasBoundDispatchReceiver -> irCall.dispatchReceiver = receiverValue + hasBoundExtensionReceiver -> irCall.extensionReceiver = receiverValue } - - if (irExtensionReceiver != null) { - if (irExtensionReceiver.isSafeToUseWithoutCopying()) { - irAdapteeCallInner.extensionReceiver = irExtensionReceiver - } else { - val irVariable = statementGenerator.scope.createTemporaryVariable(irExtensionReceiver, "receiver") - irAdapteeCallInner.extensionReceiver = IrGetValueImpl(startOffset, endOffset, irVariable.symbol) - tmpReceivers.add(irVariable) - } - } - - irAdapteeCallInner.putTypeArguments(callBuilder.typeArguments) { it.toIrType() } - - putAdaptedValueArguments(startOffset, endOffset, irAdapteeCallInner, irAdapterFun, resolvedCall) - - irAdapteeCallInner } - return AdapteeCall(irCall, tmpReceivers) + context.callToSubstitutedDescriptorMap[irCall] = resolvedDescriptor + + irCall.putTypeArguments(callBuilder.typeArguments) { it.toIrType() } + + putAdaptedValueArguments(startOffset, endOffset, irCall, irAdapterFun, resolvedCall) + + return irCall } private fun IrExpression.isSafeToUseWithoutCopying() = @@ -330,7 +324,8 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St endOffset: Int, adapteeDescriptor: FunctionDescriptor, ktExpectedParameterTypes: List, - ktExpectedReturnType: KotlinType + ktExpectedReturnType: KotlinType, + callBuilder: CallBuilder, ): IrSimpleFunction { val adapterFunctionDescriptor = WrappedSimpleFunctionDescriptor() @@ -361,34 +356,52 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St irAdapterFun.metadata = MetadataSource.Function(adapteeDescriptor) irAdapterFun.dispatchReceiverParameter = null - irAdapterFun.extensionReceiverParameter = null + + val boundReceiver = callBuilder.original.selectBoundReceiver() + if (boundReceiver != null) { + irAdapterFun.extensionReceiverParameter = + createAdapterParameter(startOffset, endOffset, Name.identifier("receiver"), -1, boundReceiver.type) + } else { + irAdapterFun.extensionReceiverParameter = null + } irAdapterFun.valueParameters += ktExpectedParameterTypes.mapIndexed { index, ktExpectedParameterType -> - val adapterValueParameterDescriptor = WrappedValueParameterDescriptor() - context.symbolTable.declareValueParameter( - startOffset, endOffset, - IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, - adapterValueParameterDescriptor, - ktExpectedParameterType.toIrType() - ) { irAdapterParameterSymbol -> - IrValueParameterImpl( - startOffset, endOffset, - IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, - irAdapterParameterSymbol, - Name.identifier("p$index"), - index, - ktExpectedParameterType.toIrType(), - varargElementType = null, isCrossinline = false, isNoinline = false - ).also { irAdapterValueParameter -> - adapterValueParameterDescriptor.bind(irAdapterValueParameter) - } - } + createAdapterParameter(startOffset, endOffset, Name.identifier("p$index"), index, ktExpectedParameterType) } } } } } + private fun ResolvedCall<*>.selectBoundReceiver(): ReceiverValue? { + val dispatchReceiver = dispatchReceiver.takeUnless { it is TransientReceiver } + val extensionReceiver = extensionReceiver.takeUnless { it is TransientReceiver } + return when { + dispatchReceiver == null -> extensionReceiver + extensionReceiver == null -> dispatchReceiver + else -> error("Bound callable references can't have both receivers: $resultingDescriptor") + } + } + + private fun createAdapterParameter(startOffset: Int, endOffset: Int, name: Name, index: Int, type: KotlinType): IrValueParameter { + val descriptor = WrappedValueParameterDescriptor() + return context.symbolTable.declareValueParameter( + startOffset, endOffset, IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, descriptor, type.toIrType() + ) { irAdapterParameterSymbol -> + IrValueParameterImpl( + startOffset, endOffset, + IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, + irAdapterParameterSymbol, + name, + index, + type.toIrType(), + varargElementType = null, isCrossinline = false, isNoinline = false + ).also { irAdapterValueParameter -> + descriptor.bind(irAdapterValueParameter) + } + } + } + fun generateCallableReference( ktElement: KtElement, type: KotlinType, diff --git a/compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt b/compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt new file mode 100644 index 00000000000..5be3db21c74 --- /dev/null +++ b/compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt @@ -0,0 +1,10 @@ +// 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) diff --git a/compiler/testData/codegen/box/callableReference/equality/capturedDefaults.kt b/compiler/testData/codegen/box/callableReference/equality/capturedDefaults.kt index 7cf4e1feb4f..1d01199a5b6 100644 --- a/compiler/testData/codegen/box/callableReference/equality/capturedDefaults.kt +++ b/compiler/testData/codegen/box/callableReference/equality/capturedDefaults.kt @@ -49,6 +49,11 @@ fun box(): String { checkNotEqual(captureNoDefaults(V::target), captureNoDefaultsBoundFromOtherFile(v0)) + val v1 = V() + checkNotEqual(captureNoDefaultsBound(v0::target), captureNoDefaultsBound(v1::target)) + checkNotEqual(captureOneDefaultBound(v0::target), captureOneDefaultBound(v1::target)) + checkNotEqual(captureAllDefaultsBound(v0::target), captureAllDefaultsBound(v1::target)) + return "OK" } diff --git a/compiler/testData/codegen/box/callableReference/equality/capturedVararg.kt b/compiler/testData/codegen/box/callableReference/equality/capturedVararg.kt index f56bdcdd891..03cbb20dbae 100644 --- a/compiler/testData/codegen/box/callableReference/equality/capturedVararg.kt +++ b/compiler/testData/codegen/box/callableReference/equality/capturedVararg.kt @@ -50,6 +50,10 @@ fun box(): String { checkNotEqual(captureVararg1Bound(v0::target), captureVarargAsArrayBound(v0::target)) checkNotEqual(captureVararg1Bound(v0::target), captureVarargAsArrayBoundFromOtherFile(v0)) + val v1 = V() + checkNotEqual(captureVararg0Bound(v0::target), captureVararg0Bound(v1::target)) + checkNotEqual(captureVarargAsArrayBound(v0::target), captureVarargAsArrayBound(v1::target)) + return "OK" } diff --git a/compiler/testData/codegen/box/callableReference/equality/coercionToUnit.kt b/compiler/testData/codegen/box/callableReference/equality/coercionToUnit.kt index 8ccd11ab8a9..79a55ff47b6 100644 --- a/compiler/testData/codegen/box/callableReference/equality/coercionToUnit.kt +++ b/compiler/testData/codegen/box/callableReference/equality/coercionToUnit.kt @@ -39,6 +39,10 @@ fun box(): String { checkNotEqual(captureStringBound(v0::target), captureUnitBound(v0::target)) checkNotEqual(captureString(V::target), captureUnitBoundFromOtherFile(v0)) + val v1 = V() + checkNotEqual(captureStringBound(v0::target), captureStringBound(v1::target)) + checkNotEqual(captureUnitBound(v0::target), captureUnitBound(v1::target)) + return "OK" } diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.txt new file mode 100644 index 00000000000..acf9f10ba56 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.fir.txt @@ -0,0 +1,18 @@ +FILE fqName:test fileName:/boundInlineAdaptedReference.kt + FUN name:foo visibility:public modality:FINAL <> (x:kotlin.Function0) returnType:kotlin.Unit [inline] + VALUE_PARAMETER name:x index:0 type:kotlin.Function0 + 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: type:kotlin.String + VALUE_PARAMETER name:s index:0 type:kotlin.String + EXPRESSION_BODY + GET_VAR ': 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: #' type=IrErrorType + FUNCTION_REFERENCE 'public final fun id (s: kotlin.String, vararg xs: kotlin.Int): kotlin.String declared in test' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + $receiver: CONST String type=kotlin.String value="Fail" diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt new file mode 100644 index 00000000000..3282a8c221f --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt @@ -0,0 +1,9 @@ +package test + +inline fun foo(x: () -> Unit) {} + +fun String.id(s: String = this, vararg xs: Int): String = s + +fun test() { + foo("Fail"::id) +} diff --git a/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.txt b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.txt new file mode 100644 index 00000000000..e11e0cc7e4e --- /dev/null +++ b/compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.txt @@ -0,0 +1,25 @@ +FILE fqName:test fileName:/boundInlineAdaptedReference.kt + FUN name:foo visibility:public modality:FINAL <> (x:kotlin.Function0) returnType:kotlin.Unit [inline] + VALUE_PARAMETER name:x index:0 type:kotlin.Function0 + 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: type:kotlin.String + VALUE_PARAMETER name:s index:0 type:kotlin.String + EXPRESSION_BODY + GET_VAR ': 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 [inline] declared in test' type=kotlin.Unit origin=null + x: BLOCK type=kotlin.Function0 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 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: CONST String type=kotlin.String value="Fail" diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt index 200a19c2bc3..0db4400bbf5 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt @@ -83,28 +83,33 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructor (outer: .Outer): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: FUN_EXPR type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.Outer.Inner + fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> ($receiver:.Outer, p0:kotlin.Int) returnType:.Outer.Inner + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Outer VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=.Outer.Inner origin=null - $outer: GET_VAR 'outer: .Outer declared in .testInnerClassConstructor' type=.Outer origin=null + $outer: GET_VAR 'receiver: .Outer declared in .testInnerClassConstructor.' type=.Outer origin=ADAPTED_FUNCTION_REFERENCE xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructor.' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'outer: .Outer declared in .testInnerClassConstructor' type=.Outer origin=null FUN name:testInnerClassConstructorCapturingOuter visibility:public modality:FINAL <> () returnType:kotlin.Any BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructorCapturingOuter (): kotlin.Any declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.Any declared in ' type=kotlin.Any origin=null - fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=null + fn: BLOCK type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Outer [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Outer' type=.Outer origin=null - FUN_EXPR type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.Outer.Inner - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' - CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=.Outer.Inner origin=null - $outer: GET_VAR 'val tmp_0: .Outer [val] declared in .testInnerClassConstructorCapturingOuter' type=.Outer origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructorCapturingOuter.' type=kotlin.Int origin=null + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> ($receiver:.Outer, p0:kotlin.Int) returnType:.Outer.Inner + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Outer + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + RETURN type=kotlin.Nothing from='local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' + CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .Outer.Inner' type=.Outer.Inner origin=null + $outer: GET_VAR 'receiver: .Outer declared in .testInnerClassConstructorCapturingOuter.' type=.Outer origin=ADAPTED_FUNCTION_REFERENCE + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .testInnerClassConstructorCapturingOuter.' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' type=kotlin.Function1.Outer.Inner> origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'val tmp_0: .Outer [val] declared in .testInnerClassConstructorCapturingOuter' type=.Outer origin=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt index 14bb8c072a2..981458ab0ef 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/unboundMemberReferenceWithAdaptedArguments.txt @@ -74,24 +74,30 @@ FILE fqName: fileName:/unboundMemberReferenceWithAdaptedArguments.kt VALUE_PARAMETER name:a index:0 type:.A BLOCK_BODY CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> ($receiver:.A, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.A VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .A' type=kotlin.Int origin=null - $this: GET_VAR 'a: .A declared in .testBound' type=.A origin=null + $this: GET_VAR 'receiver: .A declared in .testBound.foo' type=.A origin=ADAPTED_FUNCTION_REFERENCE xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testBound.foo' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.Int): kotlin.Unit declared in .testBound' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'a: .A declared in .testBound' type=.A origin=null FUN name:testObject visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun use2 (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:foo visibility:local modality:FINAL <> ($receiver:.Obj, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Obj VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public open fun foo (vararg xs: kotlin.Int): kotlin.Int declared in .Obj' type=kotlin.Int origin=null - $this: GET_OBJECT 'CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' type=.Obj + $this: GET_VAR 'receiver: .Obj declared in .testObject.foo' type=.Obj origin=ADAPTED_FUNCTION_REFERENCE xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testObject.foo' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun foo (p0: kotlin.Int): kotlin.Unit declared in .testObject' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_OBJECT 'CLASS OBJECT name:Obj modality:FINAL visibility:public superTypes:[.A]' type=.Obj diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt index c163762b702..ee0ca71d123 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt @@ -101,15 +101,16 @@ FILE fqName: fileName:/withAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testImportedObjectMember (): kotlin.String declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null - fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE FUN ADAPTER_FOR_CALLABLE_REFERENCE name:importedObjectMemberWithVarargs visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun importedObjectMemberWithVarargs (p0: kotlin.Int): kotlin.String declared in .testImportedObjectMember' CALL 'public final fun importedObjectMemberWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testImportedObjectMember.importedObjectMemberWithVarargs' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun importedObjectMemberWithVarargs (p0: kotlin.Int): kotlin.String declared in .testImportedObjectMember' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host FUN name:testDefault0 visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testDefault0 (): kotlin.String declared in ' diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt index f0f54d04a3b..d8737a88c6c 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt @@ -21,78 +21,91 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR ': .Host declared in .Host.testImplicitThis' type=.Host origin=null + $this: GET_VAR 'receiver: .Host declared in .Host.testImplicitThis.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .Host.testImplicitThis.withVararg' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testImplicitThis' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR ': .Host declared in .Host.testImplicitThis' type=.Host origin=null FUN name:testBoundReceiverLocalVal visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY VAR name:h type:.Host [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'val h: .Host [val] declared in .Host.testBoundReceiverLocalVal' type=.Host origin=null + $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverLocalVal.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverLocalVal.withVararg' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVal' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'val h: .Host [val] declared in .Host.testBoundReceiverLocalVal' type=.Host origin=null FUN name:testBoundReceiverLocalVar visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY VAR name:h type:.Host [var] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=null + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Host [val] GET_VAR 'var h: .Host [var] declared in .Host.testBoundReceiverLocalVar' type=.Host origin=null - FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'val tmp_0: .Host [val] declared in .Host.testBoundReceiverLocalVar' type=.Host origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverLocalVar.withVararg' type=kotlin.Int origin=null + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null + $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverLocalVar.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverLocalVar.withVararg' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVar' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'val tmp_0: .Host [val] declared in .Host.testBoundReceiverLocalVar' type=.Host origin=null FUN name:testBoundReceiverParameter visibility:public modality:FINAL <> ($this:.Host, h:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host VALUE_PARAMETER name:h index:0 type:.Host BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int BLOCK_BODY TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'h: .Host declared in .Host.testBoundReceiverParameter' type=.Host origin=null + $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverParameter.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverParameter.withVararg' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverParameter' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'h: .Host declared in .Host.testBoundReceiverParameter' type=.Host origin=null FUN name:testBoundReceiverExpression visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: BLOCK type=kotlin.Function1 origin=null + fn: BLOCK type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Host [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null - FUN_EXPR type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE - FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int - BLOCK_BODY - TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit - CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null - $this: GET_VAR 'val tmp_1: .Host [val] declared in .Host.testBoundReceiverExpression' type=.Host origin=null - xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int - GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverExpression.withVararg' type=kotlin.Int origin=null + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:withVararg visibility:local modality:FINAL <> ($receiver:.Host, p0:kotlin.Int) returnType:kotlin.Unit + $receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:receiver type:.Host + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + BLOCK_BODY + TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit + CALL 'public final fun withVararg (vararg xs: kotlin.Int): kotlin.String declared in .Host' type=kotlin.String origin=null + $this: GET_VAR 'receiver: .Host declared in .Host.testBoundReceiverExpression.withVararg' type=.Host origin=ADAPTED_FUNCTION_REFERENCE + xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int + GET_VAR 'p0: kotlin.Int declared in .Host.testBoundReceiverExpression.withVararg' type=kotlin.Int origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverExpression' type=kotlin.Function1 origin=ADAPTED_FUNCTION_REFERENCE reflectionTarget=null + $receiver: GET_VAR 'val tmp_1: .Host [val] declared in .Host.testBoundReceiverExpression' type=.Host origin=null FUN FAKE_OVERRIDE name:equals visibility:public modality:OPEN <> ($this:kotlin.Any, other:kotlin.Any?) returnType:kotlin.Boolean [fake_override,operator] overridden: public open fun equals (other: kotlin.Any?): kotlin.Boolean [operator] declared in kotlin.Any diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 50ef76f836a..259fccf6278 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -2045,6 +2045,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/emptyVarargAndDefault.kt"); } + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt"); + } + @TestMetadata("inlineDefault.kt") public void testInlineDefault() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineDefault.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 1b9787336b8..6da11aab555 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -2045,6 +2045,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/emptyVarargAndDefault.kt"); } + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt"); + } + @TestMetadata("inlineDefault.kt") public void testInlineDefault() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineDefault.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 0a8a2d2e66e..cdfd1009ad8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -2025,6 +2025,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/emptyVarargAndDefault.kt"); } + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt"); + } + @TestMetadata("inlineDefault.kt") public void testInlineDefault() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineDefault.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index 008897fe206..a03db31f24c 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1403,6 +1403,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/ir/irText/expressions/callableReferences"), Pattern.compile("^(.+)\\.kt$"), null, true); } + @TestMetadata("boundInlineAdaptedReference.kt") + public void testBoundInlineAdaptedReference() throws Exception { + runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInlineAdaptedReference.kt"); + } + @TestMetadata("boundInnerGenericConstructor.kt") public void testBoundInnerGenericConstructor() throws Exception { runTest("compiler/testData/ir/irText/expressions/callableReferences/boundInnerGenericConstructor.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 9b8ca8d30cf..2c32dc7b5ef 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -1470,6 +1470,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/emptyVarargAndDefault.kt"); } + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt"); + } + @TestMetadata("inlineDefault.kt") public void testInlineDefault() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineDefault.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 5565b30d886..e2a3a9eb05a 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -1470,6 +1470,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/emptyVarargAndDefault.kt"); } + @TestMetadata("inlineBound.kt") + public void testInlineBound() throws Exception { + runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineBound.kt"); + } + @TestMetadata("inlineDefault.kt") public void testInlineDefault() throws Exception { runTest("compiler/testData/codegen/box/callableReference/adaptedReferences/inlineDefault.kt");