From c540116b71296c006dec6c971cbe292912e121b9 Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Tue, 21 Jan 2020 17:01:35 +0300 Subject: [PATCH] IR: additional callable reference adapter stuff in IR - IrFunctionReference.reflectionTarget: IrFunctionSymbol? - add separate declaration origin for callable reference adapters - bump IR ABI version --- .../kotlin/fir/backend/Fir2IrVisitor.kt | 3 +- .../kotlin/fir/Fir2IrTextTestGenerated.java | 5 ++ .../common/lower/InnerClassesLowering.kt | 9 +++ .../common/lower/LocalDeclarationsLowering.kt | 2 + .../ProvisionalFunctionExpressionLowering.kt | 5 +- .../kotlin/ir/backend/js/ir/IrBuilder.kt | 4 +- .../lower/JsDefaultArgumentStubGenerator.kt | 5 +- .../js/lower/PrivateMembersLowering.kt | 2 +- .../js/lower/ScriptRemoveReceiverLowering.kt | 1 + .../jvm/lower/CallableReferenceLowering.kt | 1 + .../lower/InlineCallableReferenceToLambda.kt | 6 +- .../backend/jvm/lower/InterfaceLowering.kt | 1 + .../jvm/lower/JvmInlineClassLowering.kt | 2 +- .../jvm/lower/PropertyReferenceLowering.kt | 5 +- .../jvm/lower/SyntheticAccessorLowering.kt | 2 +- .../ReflectionReferencesGenerator.kt | 27 +++++--- .../ir/declarations/IrDeclarationOrigin.kt | 3 + .../ir/expressions/IrCallableReference.kt | 7 ++ .../impl/IrFunctionReferenceImpl.kt | 12 +++- .../ir/util/DeepCopyIrTreeWithSymbols.kt | 2 + .../kotlin/ir/util/RenderIrElement.kt | 10 ++- .../serialization.common/src/KotlinIr.proto | 1 + .../serialization/IrFileDeserializer.kt | 2 + .../common/serialization/IrFileSerializer.kt | 12 +++- .../proto/IrFunctionReference.java | 69 +++++++++++++++++++ .../proto/IrFunctionReferenceOrBuilder.java | 9 +++ .../boundCallableReferences.fir.txt | 4 +- .../expressions/boundCallableReferences.txt | 4 +- .../constructorWithAdaptedArguments.fir.txt | 6 +- .../constructorWithAdaptedArguments.txt | 18 ++--- .../callableReferences/genericMember.fir.txt | 2 +- .../callableReferences/genericMember.txt | 2 +- .../importedFromObject.fir.txt | 4 +- .../callableReferences/importedFromObject.txt | 4 +- .../callableReferences/typeArguments.fir.txt | 6 +- .../callableReferences/typeArguments.txt | 6 +- .../withAdaptedArguments.fir.txt | 8 +-- .../withAdaptedArguments.txt | 24 +++---- .../withArgumentAdaptationAndReceiver.fir.txt | 10 +-- .../withArgumentAdaptationAndReceiver.txt | 30 ++++---- .../withVarargViewedAsArray.fir.txt | 8 +-- .../withVarargViewedAsArray.txt | 18 ++--- .../samConversionOnCallableReference.fir.txt | 46 +++++++++++++ .../samConversionOnCallableReference.kt | 25 +++++++ .../samConversionOnCallableReference.txt | 48 +++++++++++++ .../samConversionsWithSmartCasts.fir.txt | 2 +- .../samConversionsWithSmartCasts.txt | 2 +- .../expressions/reflectionLiterals.fir.txt | 8 +-- .../irText/expressions/reflectionLiterals.txt | 8 +-- .../expressions/sam/samConstructors.fir.txt | 2 +- .../expressions/sam/samConstructors.txt | 2 +- .../sam/samConversionsWithSmartCasts.fir.txt | 2 +- .../sam/samConversionsWithSmartCasts.txt | 2 +- .../expressions/sam/samOperators.fir.txt | 20 +++--- .../irText/expressions/sam/samOperators.txt | 20 +++--- .../typeAliasConstructorReference.fir.txt | 4 +- .../typeAliasConstructorReference.txt | 4 +- .../kotlin/ir/IrTextTestCaseGenerated.java | 5 ++ .../kotlin/library/KotlinAbiVersion.kt | 2 +- 59 files changed, 420 insertions(+), 143 deletions(-) create mode 100644 compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.txt create mode 100644 compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt create mode 100644 compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt index 56702137c3e..136dd70509f 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrVisitor.kt @@ -911,7 +911,8 @@ class Fir2IrVisitor( is IrFunctionSymbol -> { IrFunctionReferenceImpl( startOffset, endOffset, type, symbol, - 0 + typeArgumentsCount = 0, + reflectionTarget = symbol ) } else -> { 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 1e10c2239ad..23161689b13 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/fir/Fir2IrTextTestGenerated.java @@ -1480,6 +1480,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest { runTest("compiler/testData/ir/irText/expressions/funInterface/partialSam.kt"); } + @TestMetadata("samConversionOnCallableReference.kt") + public void testSamConversionOnCallableReference() throws Exception { + runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt"); + } + @TestMetadata("samConversionsWithSmartCasts.kt") public void testSamConversionsWithSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt"); diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt index 5f0f6fcfbee..23d87d3bfca 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/InnerClassesLowering.kt @@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.util.patchDeclarationParents import org.jetbrains.kotlin.ir.util.transformDeclarationsFlat import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid +import org.jetbrains.kotlin.utils.addToStdlib.cast class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass { private val IrValueSymbol.classForImplicitThis: IrClass? @@ -170,6 +171,13 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : FileLowe if (!parent.isInner) return expression val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(callee.owner) + val newReflectionTarget = expression.reflectionTarget?.let { reflectionTarget -> + if (reflectionTarget is IrConstructorSymbol) { + context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(reflectionTarget.owner) + } else { + null + } + } val newReference = expression.run { IrFunctionReferenceImpl( @@ -178,6 +186,7 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : FileLowe type, newCallee.symbol, typeArgumentsCount, + newReflectionTarget?.symbol, origin ) } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt index 2cccc5a1143..d7a55cf0861 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt @@ -383,12 +383,14 @@ class LocalDeclarationsLowering( val oldCallee = expression.symbol.owner val newCallee = oldCallee.transformed ?: return expression + val newReflectionTarget = expression.reflectionTarget?.run { owner.transformed } return IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type, // TODO functional type for transformed descriptor newCallee.symbol, newCallee.typeParameters.size, + newReflectionTarget?.symbol, expression.origin ).also { it.fillArguments2(expression, newCallee) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt index b372358ed08..2fe4dd1c8d3 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/ProvisionalFunctionExpressionLowering.kt @@ -37,7 +37,10 @@ class ProvisionalFunctionExpressionLowering : function, IrFunctionReferenceImpl( startOffset, endOffset, type, - function.symbol, 0, origin + function.symbol, + typeArgumentsCount = 0, + reflectionTarget = null, + origin = origin ) ) ) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt index 2d63a567e65..99ac8ba1ec7 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/ir/IrBuilder.kt @@ -188,8 +188,8 @@ object JsIrBuilder { fun buildComposite(type: IrType, statements: List = emptyList()) = IrCompositeImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, SYNTHESIZED_STATEMENT, statements) - fun buildFunctionReference(type: IrType, symbol: IrFunctionSymbol) = - IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, symbol, 0, null) + fun buildFunctionReference(type: IrType, symbol: IrFunctionSymbol, reflectionTarget: IrFunctionSymbol? = symbol) = + IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, symbol, 0, reflectionTarget, null) fun buildVar( type: IrType, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt index 5996dad2fdb..b7ca5894796 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/JsDefaultArgumentStubGenerator.kt @@ -79,8 +79,9 @@ class JsDefaultCallbackGenerator(val context: JsIrBackendContext): BodyLoweringP endOffset, context.irBuiltIns.anyType, originalFunction.symbol, - 0, - BIND_CALL + typeArgumentsCount = 0, + reflectionTarget = originalFunction.symbol, + origin = BIND_CALL ) } diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt index 769e55ed75d..d5a0d6ee86c 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/PrivateMembersLowering.kt @@ -80,7 +80,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : FileLoweringPass expression.startOffset, expression.endOffset, expression.type, it.symbol, expression.typeArgumentsCount, - expression.valueArgumentsCount, expression.origin + expression.valueArgumentsCount, expression.reflectionTarget, expression.origin ) } } ?: expression diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt index be79c9325b5..80116125415 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ScriptRemoveReceiverLowering.kt @@ -77,6 +77,7 @@ private class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : symbol, typeArgumentsCount, valueArgumentsCount, + reflectionTarget, origin ).also { it.dispatchReceiver = dispatchReceiver diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt index c2b20181555..773fe39ddc2 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/CallableReferenceLowering.kt @@ -334,6 +334,7 @@ internal class CallableReferenceLowering(private val context: JvmBackendContext) irFunctionReference.type, irFunctionReference.symbol, 0, + irFunctionReference.reflectionTarget, null ) ) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt index 0045acca942..791a5ec4242 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InlineCallableReferenceToLambda.kt @@ -106,6 +106,7 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte field.type, function.symbol, typeArgumentsCount = 0, + reflectionTarget = null, origin = IrStatementOrigin.LAMBDA ).apply { copyAttributes(expression) @@ -174,8 +175,9 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte expression.endOffset, function.returnType, function.symbol, - function.typeParameters.size, - IrStatementOrigin.LAMBDA + typeArgumentsCount = function.typeParameters.size, + reflectionTarget = null, + origin = IrStatementOrigin.LAMBDA ).apply { copyAttributes(expression) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt index 8989f7ccad0..fa398322354 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/InterfaceLowering.kt @@ -261,6 +261,7 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran type, newFunction.symbol, typeArgumentsCount, + expression.reflectionTarget, origin ).apply { copyTypeAndValueArgumentsFrom(expression, receiversAsArguments = true) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt index ca00a332eeb..62e4f27df48 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmInlineClassLowering.kt @@ -229,7 +229,7 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F return IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type, function.symbol, function.typeParameters.size, - function.valueParameters.size, expression.origin + function.valueParameters.size, expression.reflectionTarget, expression.origin ).apply { buildReplacement(expression.symbol.owner, expression, replacement) }.copyAttributes(expression) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt index 5ad883758c2..564794b1d76 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PropertyReferenceLowering.kt @@ -105,7 +105,10 @@ internal class PropertyReferenceLowering(val context: JvmBackendContext) : Class // Delay the computation of the signature until after inline classes lowering to make sure // we mangle the function names correctly for things like extension methods on inline classes. irCall(signatureStringIntrinsic).apply { - putValueArgument(0, IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, expression.type, getter, 0, null)) + putValueArgument( + 0, + IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, expression.type, getter, 0, getter, null) + ) } } } ?: irString(expression.field!!.owner.signature) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt index fee3cb26c38..3239f3ac9f3 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/SyntheticAccessorLowering.kt @@ -122,7 +122,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle return IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type, accessor.symbol, accessor.typeParameters.size, - accessor.valueParameters.size, expression.origin + accessor.valueParameters.size, accessor.symbol, expression.origin ) } } 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 3a5fbfda2fb..33179c5f6b1 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 @@ -98,8 +98,6 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St } } - private val adapterOrigin = IrDeclarationOrigin.DEFINED // TODO special declaration origin for callable reference adapter? - private fun isTrivialArgumentAdaptation(irAdapteeCall: IrFunctionAccessExpression): Boolean { for (i in 0 until irAdapteeCall.valueArgumentsCount) { val irValueArgument = irAdapteeCall.getValueArgument(i) ?: return false @@ -162,8 +160,9 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St startOffset, endOffset, irFunctionalType, irAdapterFun.symbol, - 0, - irAdapterFun.valueParameters.size + typeArgumentsCount = 0, + valueArgumentsCount = irAdapterFun.valueParameters.size, + reflectionTarget = null ) ) } @@ -341,12 +340,14 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St ): IrSimpleFunction { val adapterFunctionDescriptor = WrappedSimpleFunctionDescriptor() - return context.symbolTable.declareSimpleFunction( - startOffset, endOffset, adapterOrigin, adapterFunctionDescriptor + startOffset, endOffset, + IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE, + adapterFunctionDescriptor ) { irAdapterSymbol -> IrFunctionImpl( - startOffset, endOffset, adapterOrigin, + startOffset, endOffset, + IrDeclarationOrigin.ADAPTER_FOR_CALLABLE_REFERENCE, irAdapterSymbol, adapteeDescriptor.name, Visibilities.LOCAL, @@ -371,11 +372,14 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St ktExpectedParameterTypes.mapIndexedTo(irAdapterFun.valueParameters) { index, ktExpectedParameterType -> val adapterValueParameterDescriptor = WrappedValueParameterDescriptor() context.symbolTable.declareValueParameter( - startOffset, endOffset, adapterOrigin, adapterValueParameterDescriptor, + startOffset, endOffset, + IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, + adapterValueParameterDescriptor, ktExpectedParameterType.toIrType() ) { irAdapterParameterSymbol -> IrValueParameterImpl( - startOffset, endOffset, adapterOrigin, + startOffset, endOffset, + IrDeclarationOrigin.ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE, irAdapterParameterSymbol, Name.identifier("p$index"), index, @@ -487,7 +491,10 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St ): IrFunctionReference = IrFunctionReferenceImpl( startOffset, endOffset, type.toIrType(), - symbol, descriptor.typeParametersCount, origin + symbol, + typeArgumentsCount = descriptor.typeParametersCount, + reflectionTarget = symbol, + origin = origin ).apply { context.callToSubstitutedDescriptorMap[this] = descriptor putTypeArguments(typeArguments) { it.toIrType() } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt index 9859317a137..b8c809100fd 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/IrDeclarationOrigin.kt @@ -53,6 +53,9 @@ interface IrDeclarationOrigin { object FIELD_FOR_ENUM_VALUES : IrDeclarationOriginImpl("FIELD_FOR_ENUM_VALUES", isSynthetic = true) object FIELD_FOR_OBJECT_INSTANCE : IrDeclarationOriginImpl("FIELD_FOR_OBJECT_INSTANCE") + object ADAPTER_FOR_CALLABLE_REFERENCE : IrDeclarationOriginImpl("ADAPTER_FOR_CALLABLE_REFERENCE") + object ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE : IrDeclarationOriginImpl("ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE") + val isSynthetic: Boolean get() = false } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt index ee16fa82766..41706b0ba53 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/IrCallableReference.kt @@ -22,8 +22,15 @@ interface IrCallableReference : IrMemberAccessExpression interface IrFunctionReference : IrCallableReference { override val symbol: IrFunctionSymbol + val reflectionTarget: IrFunctionSymbol? } +val IrFunctionReference.isWithReflection: Boolean + get() = reflectionTarget != null + +val IrFunctionReference.isAdapterWithReflection: Boolean + get() = reflectionTarget != null && reflectionTarget != symbol + interface IrPropertyReference : IrCallableReference { override val symbol: IrPropertySymbol val field: IrFieldSymbol? diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt index 65196611e55..5f2a7fb82df 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrFunctionReferenceImpl.kt @@ -29,6 +29,7 @@ class IrFunctionReferenceImpl( override val symbol: IrFunctionSymbol, typeArgumentsCount: Int, valueArgumentsCount: Int, + override val reflectionTarget: IrFunctionSymbol? = symbol, origin: IrStatementOrigin? = null ) : IrCallWithIndexedArgumentsBase( @@ -47,8 +48,17 @@ class IrFunctionReferenceImpl( type: IrType, symbol: IrFunctionSymbol, typeArgumentsCount: Int, + reflectionTarget: IrFunctionSymbol?, origin: IrStatementOrigin? = null - ) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size, origin) + ) : this( + startOffset, endOffset, + type, + symbol, + typeArgumentsCount, + symbol.descriptor.valueParameters.size, + reflectionTarget, + origin + ) override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitFunctionReference(this, data) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt index 4a7b6c44122..717c7b8e087 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/DeepCopyIrTreeWithSymbols.kt @@ -584,12 +584,14 @@ open class DeepCopyIrTreeWithSymbols( override fun visitFunctionReference(expression: IrFunctionReference): IrFunctionReference { val symbol = symbolRemapper.getReferencedFunction(expression.symbol) + val reflectionTarget = expression.reflectionTarget?.let { symbolRemapper.getReferencedFunction(it) } return IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type.remapType(), symbol, expression.typeArgumentsCount, expression.valueArgumentsCount, + reflectionTarget, mapStatementOrigin(expression.origin) ).apply { copyRemappedTypeArgumentsFrom(expression) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt index 92cc9186eff..48dcbdeb139 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/RenderIrElement.kt @@ -635,7 +635,15 @@ class RenderIrElementVisitor(private val normalizeNames: Boolean = false) : IrEl "THROW type=${expression.type.render()}" override fun visitFunctionReference(expression: IrFunctionReference, data: Nothing?): String = - "FUNCTION_REFERENCE '${expression.symbol.renderReference()}' type=${expression.type.render()} origin=${expression.origin}" + "FUNCTION_REFERENCE '${expression.symbol.renderReference()}' " + + "type=${expression.type.render()} origin=${expression.origin} " + + "reflectionTarget=${renderReflectionTarget(expression)}" + + private fun renderReflectionTarget(expression: IrFunctionReference) = + if (expression.symbol == expression.reflectionTarget) + "" + else + expression.reflectionTarget?.renderReference() override fun visitPropertyReference(expression: IrPropertyReference, data: Nothing?): String = buildTrimEnd { diff --git a/compiler/ir/serialization.common/src/KotlinIr.proto b/compiler/ir/serialization.common/src/KotlinIr.proto index 6afeab3fbaa..ca806583faa 100644 --- a/compiler/ir/serialization.common/src/KotlinIr.proto +++ b/compiler/ir/serialization.common/src/KotlinIr.proto @@ -219,6 +219,7 @@ message IrFunctionReference { required int32 symbol = 1; optional IrStatementOrigin origin = 2; required MemberAccessCommon member_access = 3; + optional int32 reflectionTarget = 4; } message IrLocalDelegatedPropertyReference { diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt index 5ed26eb9863..c42f2274f02 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileDeserializer.kt @@ -448,6 +448,7 @@ abstract class IrFileDeserializer( val symbol = deserializeIrSymbol(proto.symbol) as IrFunctionSymbol val origin = if (proto.hasOrigin()) deserializeIrStatementOrigin(proto.origin) else null + val reflectionTarget = if (proto.hasReflectionTarget()) deserializeIrSymbol(proto.reflectionTarget) as IrFunctionSymbol else null val callable = IrFunctionReferenceImpl( start, end, @@ -455,6 +456,7 @@ abstract class IrFileDeserializer( symbol, proto.memberAccess.typeArguments.typeArgumentCount, proto.memberAccess.valueArgumentCount, + reflectionTarget, origin ) deserializeMemberAccessCommon(callable, proto.memberAccess) diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt index 3d123c0c20e..e8480f67823 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/IrFileSerializer.kt @@ -8,7 +8,6 @@ package org.jetbrains.kotlin.backend.common.serialization import org.jetbrains.kotlin.backend.common.LoggingContext import org.jetbrains.kotlin.backend.common.ir.ir2string import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.ClassKind.* import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.SourceManager @@ -18,7 +17,6 @@ import org.jetbrains.kotlin.ir.symbols.* import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.findTopLevelDeclaration import org.jetbrains.kotlin.ir.util.lineStartOffsets -import org.jetbrains.kotlin.ir.util.module import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid import org.jetbrains.kotlin.ir.visitors.acceptVoid @@ -31,6 +29,7 @@ import org.jetbrains.kotlin.library.impl.IrMemoryDeclarationWriter import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual import org.jetbrains.kotlin.backend.common.serialization.proto.ClassKind as ProtoClassKind import org.jetbrains.kotlin.backend.common.serialization.proto.Coordinates as ProtoCoordinates import org.jetbrains.kotlin.backend.common.serialization.proto.FieldAccessCommon as ProtoFieldAccessCommon @@ -116,7 +115,6 @@ import org.jetbrains.kotlin.backend.common.serialization.proto.ModalityKind as P import org.jetbrains.kotlin.backend.common.serialization.proto.NullableIrExpression as ProtoNullableIrExpression import org.jetbrains.kotlin.backend.common.serialization.proto.TypeArguments as ProtoTypeArguments import org.jetbrains.kotlin.backend.common.serialization.proto.Visibility as ProtoVisibility -import org.jetbrains.kotlin.backend.common.serialization.proto.Actual as ProtoActual open class IrFileSerializer( val logger: LoggingContext, @@ -542,6 +540,14 @@ open class IrFileSerializer( val proto = ProtoFunctionReference.newBuilder() .setSymbol(serializeIrSymbol(callable.symbol)) .setMemberAccess(serializeMemberAccessCommon(callable)) + .apply { + val reflectionTarget = callable.reflectionTarget + if (reflectionTarget != null) { + setReflectionTarget(serializeIrSymbol(reflectionTarget)) + } else { + clearReflectionTarget() + } + } callable.origin?.let { proto.setOrigin(serializeIrStatementOrigin(it)) } return proto.build() diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReference.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReference.java index 7d9a86c34c3..16e6e121bcb 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReference.java +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReference.java @@ -84,6 +84,11 @@ public final class IrFunctionReference extends bitField0_ |= 0x00000004; break; } + case 32: { + bitField0_ |= 0x00000008; + reflectionTarget_ = input.readInt32(); + break; + } } } } catch (org.jetbrains.kotlin.protobuf.InvalidProtocolBufferException e) { @@ -163,10 +168,26 @@ public final class IrFunctionReference extends return memberAccess_; } + public static final int REFLECTIONTARGET_FIELD_NUMBER = 4; + private int reflectionTarget_; + /** + * optional int32 reflectionTarget = 4; + */ + public boolean hasReflectionTarget() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int32 reflectionTarget = 4; + */ + public int getReflectionTarget() { + return reflectionTarget_; + } + private void initFields() { symbol_ = 0; origin_ = org.jetbrains.kotlin.backend.common.serialization.proto.IrStatementOrigin.getDefaultInstance(); memberAccess_ = org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon.getDefaultInstance(); + reflectionTarget_ = 0; } private byte memoizedIsInitialized = -1; public final boolean isInitialized() { @@ -208,6 +229,9 @@ public final class IrFunctionReference extends if (((bitField0_ & 0x00000004) == 0x00000004)) { output.writeMessage(3, memberAccess_); } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + output.writeInt32(4, reflectionTarget_); + } output.writeRawBytes(unknownFields); } @@ -229,6 +253,10 @@ public final class IrFunctionReference extends size += org.jetbrains.kotlin.protobuf.CodedOutputStream .computeMessageSize(3, memberAccess_); } + if (((bitField0_ & 0x00000008) == 0x00000008)) { + size += org.jetbrains.kotlin.protobuf.CodedOutputStream + .computeInt32Size(4, reflectionTarget_); + } size += unknownFields.size(); memoizedSerializedSize = size; return size; @@ -329,6 +357,8 @@ public final class IrFunctionReference extends bitField0_ = (bitField0_ & ~0x00000002); memberAccess_ = org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000004); + reflectionTarget_ = 0; + bitField0_ = (bitField0_ & ~0x00000008); return this; } @@ -364,6 +394,10 @@ public final class IrFunctionReference extends to_bitField0_ |= 0x00000004; } result.memberAccess_ = memberAccess_; + if (((from_bitField0_ & 0x00000008) == 0x00000008)) { + to_bitField0_ |= 0x00000008; + } + result.reflectionTarget_ = reflectionTarget_; result.bitField0_ = to_bitField0_; return result; } @@ -379,6 +413,9 @@ public final class IrFunctionReference extends if (other.hasMemberAccess()) { mergeMemberAccess(other.getMemberAccess()); } + if (other.hasReflectionTarget()) { + setReflectionTarget(other.getReflectionTarget()); + } setUnknownFields( getUnknownFields().concat(other.unknownFields)); return this; @@ -577,6 +614,38 @@ public final class IrFunctionReference extends return this; } + private int reflectionTarget_ ; + /** + * optional int32 reflectionTarget = 4; + */ + public boolean hasReflectionTarget() { + return ((bitField0_ & 0x00000008) == 0x00000008); + } + /** + * optional int32 reflectionTarget = 4; + */ + public int getReflectionTarget() { + return reflectionTarget_; + } + /** + * optional int32 reflectionTarget = 4; + */ + public Builder setReflectionTarget(int value) { + bitField0_ |= 0x00000008; + reflectionTarget_ = value; + + return this; + } + /** + * optional int32 reflectionTarget = 4; + */ + public Builder clearReflectionTarget() { + bitField0_ = (bitField0_ & ~0x00000008); + reflectionTarget_ = 0; + + return this; + } + // @@protoc_insertion_point(builder_scope:org.jetbrains.kotlin.backend.common.serialization.proto.IrFunctionReference) } diff --git a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReferenceOrBuilder.java b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReferenceOrBuilder.java index ae16e206ff0..834146e4640 100644 --- a/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReferenceOrBuilder.java +++ b/compiler/ir/serialization.common/src/org/jetbrains/kotlin/backend/common/serialization/proto/IrFunctionReferenceOrBuilder.java @@ -33,4 +33,13 @@ public interface IrFunctionReferenceOrBuilder extends * required .org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon member_access = 3; */ org.jetbrains.kotlin.backend.common.serialization.proto.MemberAccessCommon getMemberAccess(); + + /** + * optional int32 reflectionTarget = 4; + */ + boolean hasReflectionTarget(); + /** + * optional int32 reflectionTarget = 4; + */ + int getReflectionTarget(); } \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt b/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt index 10c541d31fe..c5863879f91 100644 --- a/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt +++ b/compiler/testData/ir/irText/expressions/boundCallableReferences.fir.txt @@ -38,7 +38,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -56,7 +56,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun qux (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun qux (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/boundCallableReferences.txt b/compiler/testData/ir/irText/expressions/boundCallableReferences.txt index 4babfe2f314..58f267076cb 100644 --- a/compiler/testData/ir/irText/expressions/boundCallableReferences.txt +++ b/compiler/testData/ir/irText/expressions/boundCallableReferences.txt @@ -38,7 +38,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] @@ -58,7 +58,7 @@ FILE fqName: fileName:/boundCallableReferences.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun qux (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun qux (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= $receiver: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt index 83d08684c32..76829013e19 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.fir.txt @@ -69,15 +69,15 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testConstructor (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public constructor (xs: kotlin.IntArray) [primary] declared in .C' type=kotlin.reflect.KFunction1.C> origin=null + FUNCTION_REFERENCE 'public constructor (xs: kotlin.IntArray) [primary] declared in .C' type=kotlin.reflect.KFunction1.C> origin=null reflectionTarget= FUN name:testInnerClassConstructor visibility:public modality:FINAL <> (outer:.Outer) returnType:IrErrorType VALUE_PARAMETER name:outer index:0 type:.Outer BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructor (outer: .Outer): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public constructor (xs: kotlin.IntArray) [primary] declared in .Outer.Inner' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null + FUNCTION_REFERENCE 'public constructor (xs: kotlin.IntArray) [primary] declared in .Outer.Inner' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null reflectionTarget= FUN name:testInnerClassConstructorCapturingOuter visibility:public modality:FINAL <> () returnType:IrErrorType BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testInnerClassConstructorCapturingOuter (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public constructor (xs: kotlin.IntArray) [primary] declared in .Outer.Inner' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null + FUNCTION_REFERENCE 'public constructor (xs: kotlin.IntArray) [primary] declared in .Outer.Inner' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt index c520a16c84a..3ff5c6353b4 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/constructorWithAdaptedArguments.txt @@ -71,29 +71,29 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt RETURN type=kotlin.Nothing from='public final fun testConstructor (): 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.reflect.KFunction1.C> origin=null - FUN name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.C - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + FUN ADAPTER_FOR_CALLABLE_REFERENCE name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.C + 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): .C declared in .testConstructor' CONSTRUCTOR_CALL 'public constructor (vararg xs: kotlin.Int) [primary] declared in .C' type=.C origin=null xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testConstructor.' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .C declared in .testConstructor' type=kotlin.reflect.KFunction1.C> origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .C declared in .testConstructor' type=kotlin.reflect.KFunction1.C> origin=null reflectionTarget=null FUN name:testInnerClassConstructor visibility:public modality:FINAL <> (outer:.Outer) returnType:kotlin.Any VALUE_PARAMETER name:outer index:0 type:.Outer 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: BLOCK type=kotlin.reflect.KFunction1.Outer.Inner> origin=null - FUN name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.Outer.Inner - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 .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 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.reflect.KFunction1.Outer.Inner> origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructor' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null reflectionTarget=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 ' @@ -101,12 +101,12 @@ FILE fqName: fileName:/constructorWithAdaptedArguments.kt fn: BLOCK type=kotlin.reflect.KFunction1.Outer.Inner> origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:.Outer [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Outer' type=.Outer origin=null - FUN name: visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:.Outer.Inner - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 - FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null + FUNCTION_REFERENCE 'local final fun (p0: kotlin.Int): .Outer.Inner declared in .testInnerClassConstructorCapturingOuter' type=kotlin.reflect.KFunction1.Outer.Inner> origin=null reflectionTarget=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericMember.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericMember.fir.txt index f40447c681e..cc40327b553 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/genericMember.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericMember.fir.txt @@ -36,7 +36,7 @@ FILE fqName: fileName:/genericMember.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KFunction1<.A<*>, kotlin.Unit> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A<*>, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A<*>, kotlin.Unit> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<.A<*>, kotlin.Unit> correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/genericMember.txt b/compiler/testData/ir/irText/expressions/callableReferences/genericMember.txt index ca62bb0bfcb..01c1595f4ce 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/genericMember.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/genericMember.txt @@ -36,7 +36,7 @@ FILE fqName: fileName:/genericMember.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.reflect.KFunction1<.A, kotlin.Unit> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A, kotlin.Unit> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<.A, kotlin.Unit> correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt index 518e97e4b09..44ddc690136 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.fir.txt @@ -55,7 +55,7 @@ FILE fqName:test fileName:/importedFromObject.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -64,7 +64,7 @@ FILE fqName:test fileName:/importedFromObject.kt PROPERTY name:test2a visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2a type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test2a visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.txt b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.txt index c5002c7a0fd..b1f4c47b588 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/importedFromObject.txt @@ -57,7 +57,7 @@ FILE fqName:test fileName:/importedFromObject.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= $this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=test.Foo FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] @@ -67,7 +67,7 @@ FILE fqName:test fileName:/importedFromObject.kt PROPERTY name:test2a visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2a type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.String declared in test.Foo' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= $this: GET_OBJECT 'CLASS OBJECT name:Foo modality:FINAL visibility:public superTypes:[kotlin.Any]' type=test.Foo FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test2a visibility:public modality:FINAL [val] diff --git a/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt index 2549cc0b035..c26125bd188 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.fir.txt @@ -34,7 +34,7 @@ FILE fqName: fileName:/typeArguments.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Function1 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun topLevel1 (x: T of .topLevel1): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun topLevel1 (x: T of .topLevel1): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -43,7 +43,7 @@ FILE fqName: fileName:/typeArguments.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function1, kotlin.Unit> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun topLevel2 (x: kotlin.collections.List.topLevel2>): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun topLevel2 (x: kotlin.collections.List.topLevel2>): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1, kotlin.Unit> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.Unit> correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -52,7 +52,7 @@ FILE fqName: fileName:/typeArguments.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Function1 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun objectMember (x: T of .Host.objectMember): kotlin.Unit [inline] declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun objectMember (x: T of .Host.objectMember): kotlin.Unit [inline] declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.txt index 771af5c37ff..47d97523bbe 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/typeArguments.txt @@ -34,7 +34,7 @@ FILE fqName: fileName:/typeArguments.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Function1 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun topLevel1 (x: T of .topLevel1): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun topLevel1 (x: T of .topLevel1): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, kotlin.Unit> origin=null reflectionTarget= : kotlin.Int FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] @@ -44,7 +44,7 @@ FILE fqName: fileName:/typeArguments.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function1, kotlin.Unit> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun topLevel2 (x: kotlin.collections.List.topLevel2>): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.collections.List, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun topLevel2 (x: kotlin.collections.List.topLevel2>): kotlin.Unit [inline] declared in ' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.collections.List, kotlin.Unit> origin=null reflectionTarget= : kotlin.String FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1, kotlin.Unit> correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] @@ -54,7 +54,7 @@ FILE fqName: fileName:/typeArguments.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.Function1 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun objectMember (x: T of .Host.objectMember): kotlin.Unit [inline] declared in .Host' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun objectMember (x: T of .Host.objectMember): kotlin.Unit [inline] declared in .Host' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, kotlin.Unit> origin=null reflectionTarget= : kotlin.Int $this: GET_OBJECT 'CLASS OBJECT name:Host modality:FINAL visibility:public superTypes:[kotlin.Any]' type=.Host FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1 diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt index 1dc12a7259a..35f05f7e947 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.fir.txt @@ -51,19 +51,19 @@ FILE fqName: fileName:/withAdaptedArguments.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testDefault (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction2 origin=null + FUNCTION_REFERENCE 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction2 origin=null reflectionTarget= FUN name:testVararg visibility:public modality:FINAL <> () returnType:IrErrorType BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testVararg (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun fnWithVarargs (xs: kotlin.IntArray): kotlin.String declared in ' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun fnWithVarargs (xs: kotlin.IntArray): kotlin.String declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testCoercionToUnit visibility:public modality:FINAL <> () returnType:IrErrorType BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testCoercionToUnit (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction2 origin=null + FUNCTION_REFERENCE 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.reflect.KFunction2 origin=null reflectionTarget= FUN name:testImportedObjectMember visibility:public modality:FINAL <> () returnType:IrErrorType BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testImportedObjectMember (): IrErrorType declared in ' ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun importedObjectMemberWithVarargs (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun importedObjectMemberWithVarargs (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt index 4eb4c8d8c24..c8361ace1a6 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withAdaptedArguments.txt @@ -52,49 +52,49 @@ FILE fqName: fileName:/withAdaptedArguments.kt RETURN type=kotlin.Nothing from='public final fun testDefault (): kotlin.String declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null fn: BLOCK type=kotlin.reflect.KFunction1 origin=null - FUN name:fnWithDefault visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefault 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 fnWithDefault (p0: kotlin.Int): kotlin.String declared in .testDefault' CALL 'public final fun fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null a: GET_VAR 'p0: kotlin.Int declared in .testDefault.fnWithDefault' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnWithDefault (p0: kotlin.Int): kotlin.String declared in .testDefault' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun fnWithDefault (p0: kotlin.Int): kotlin.String declared in .testDefault' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null FUN name:testVararg visibility:public modality:FINAL <> () returnType:kotlin.String BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testVararg (): kotlin.String declared in ' CALL 'public final fun use (fn: kotlin.Function1): kotlin.String declared in ' type=kotlin.String origin=null fn: BLOCK type=kotlin.reflect.KFunction1 origin=null - FUN name:fnWithVarargs visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithVarargs 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 fnWithVarargs (p0: kotlin.Int): kotlin.String declared in .testVararg' CALL 'public final fun fnWithVarargs (vararg xs: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null xs: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testVararg.fnWithVarargs' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnWithVarargs (p0: kotlin.Int): kotlin.String declared in .testVararg' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun fnWithVarargs (p0: kotlin.Int): kotlin.String declared in .testVararg' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null FUN name:testCoercionToUnit visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun testCoercionToUnit (): kotlin.Unit declared in ' CALL 'public final fun coerceToUnit (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null fn: BLOCK type=kotlin.reflect.KFunction1 origin=null - FUN name:fnWithDefault visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:fnWithDefault 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 fnWithDefault (a: kotlin.Int, b: kotlin.Int): kotlin.String declared in ' type=kotlin.String origin=null a: GET_VAR 'p0: kotlin.Int declared in .testCoercionToUnit.fnWithDefault' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun fnWithDefault (p0: kotlin.Int): kotlin.Unit declared in .testCoercionToUnit' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun fnWithDefault (p0: kotlin.Int): kotlin.Unit declared in .testCoercionToUnit' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null FUN name:testImportedObjectMember visibility:public modality:FINAL <> () returnType:kotlin.String 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: BLOCK type=kotlin.reflect.KFunction1 origin=null - FUN name:importedObjectMemberWithVarargs visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.String - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun importedObjectMemberWithVarargs (p0: kotlin.Int): kotlin.String declared in .testImportedObjectMember' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt index 8e389b6ed43..e771f4e8c42 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.fir.txt @@ -21,32 +21,32 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= 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 ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= 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 ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= 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 ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testBoundReceiverExpression visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun withVararg (xs: kotlin.IntArray): kotlin.String declared in .Host' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= 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/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt index 605d74a14bd..03641def909 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withArgumentAdaptationAndReceiver.txt @@ -22,15 +22,15 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt BLOCK_BODY CALL 'public final fun use (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null fn: BLOCK type=kotlin.reflect.KFunction1 origin=null - FUN name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 ': .Host declared in .Host.testImplicitThis' type=.Host origin=null 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.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testImplicitThis' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null FUN name:testBoundReceiverLocalVal visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY @@ -38,15 +38,15 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt 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.reflect.KFunction1 origin=null - FUN name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 h: .Host [val] declared in .Host.testBoundReceiverLocalVal' type=.Host origin=null 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.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVal' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null FUN name:testBoundReceiverLocalVar visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY @@ -56,30 +56,30 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt fn: BLOCK type=kotlin.reflect.KFunction1 origin=null 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 name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVar' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverLocalVar' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=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: BLOCK type=kotlin.reflect.KFunction1 origin=null - FUN name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 'h: .Host declared in .Host.testBoundReceiverParameter' type=.Host origin=null 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.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverParameter' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=null FUN name:testBoundReceiverExpression visibility:public modality:FINAL <> ($this:.Host) returnType:kotlin.Unit $this: VALUE_PARAMETER name: type:.Host BLOCK_BODY @@ -87,15 +87,15 @@ FILE fqName: fileName:/withArgumentAdaptationAndReceiver.kt fn: BLOCK type=kotlin.reflect.KFunction1 origin=null VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Host [val] CONSTRUCTOR_CALL 'public constructor () [primary] declared in .Host' type=.Host origin=null - FUN name:withVararg visibility:local modality:FINAL <> (p0:kotlin.Int) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int + 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 - FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverExpression' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'local final fun withVararg (p0: kotlin.Int): kotlin.Unit declared in .Host.testBoundReceiverExpression' type=kotlin.reflect.KFunction1 origin=null reflectionTarget=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/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt index b6763dea0bc..8e1c3436649 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.fir.txt @@ -59,16 +59,16 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt FUN name:testPlainArgs visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun sum (args: kotlin.IntArray): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null + FUNCTION_REFERENCE 'public final fun sum (args: kotlin.IntArray): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testPrimitiveArrayAsVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun usePrimitiveArray (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun sum (args: kotlin.IntArray): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null + fn: FUNCTION_REFERENCE 'public final fun sum (args: kotlin.IntArray): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testArrayAsVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun nsum (args: kotlin.Array): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null + FUNCTION_REFERENCE 'public final fun nsum (args: kotlin.Array): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null reflectionTarget= FUN name:testArrayAndDefaults visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY ERROR_CALL 'Unresolved reference: #' type=IrErrorType - FUNCTION_REFERENCE 'public final fun zap (b: kotlin.Array, k: kotlin.Int): kotlin.Unit declared in ' type=kotlin.reflect.KFunction2, kotlin.Int, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun zap (b: kotlin.Array, k: kotlin.Int): kotlin.Unit declared in ' type=kotlin.reflect.KFunction2, kotlin.Int, kotlin.Unit> origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt index 2002fe994fb..46e3e9e3c68 100644 --- a/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt +++ b/compiler/testData/ir/irText/expressions/callableReferences/withVarargViewedAsArray.txt @@ -62,33 +62,33 @@ FILE fqName: fileName:/withVarargViewedAsArray.kt BLOCK_BODY CALL 'public final fun usePlainArgs (fn: kotlin.Function2): kotlin.Unit declared in ' type=kotlin.Unit origin=null fn: BLOCK type=kotlin.reflect.KFunction2 origin=null - FUN name:sum visibility:local modality:FINAL <> (p0:kotlin.Int, p1:kotlin.Int) returnType:kotlin.Int - VALUE_PARAMETER name:p0 index:0 type:kotlin.Int - VALUE_PARAMETER name:p1 index:1 type:kotlin.Int + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:sum visibility:local modality:FINAL <> (p0:kotlin.Int, p1:kotlin.Int) returnType:kotlin.Int + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Int + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p1 index:1 type:kotlin.Int BLOCK_BODY RETURN type=kotlin.Nothing from='local final fun sum (p0: kotlin.Int, p1: kotlin.Int): kotlin.Int declared in .testPlainArgs' CALL 'public final fun sum (vararg args: kotlin.Int): kotlin.Int declared in ' type=kotlin.Int origin=null args: VARARG type=kotlin.IntArray varargElementType=kotlin.Int GET_VAR 'p0: kotlin.Int declared in .testPlainArgs.sum' type=kotlin.Int origin=null GET_VAR 'p1: kotlin.Int declared in .testPlainArgs.sum' type=kotlin.Int origin=null - FUNCTION_REFERENCE 'local final fun sum (p0: kotlin.Int, p1: kotlin.Int): kotlin.Int declared in .testPlainArgs' type=kotlin.reflect.KFunction2 origin=null + FUNCTION_REFERENCE 'local final fun sum (p0: kotlin.Int, p1: kotlin.Int): kotlin.Int declared in .testPlainArgs' type=kotlin.reflect.KFunction2 origin=null reflectionTarget=null FUN name:testPrimitiveArrayAsVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun usePrimitiveArray (fn: kotlin.Function1): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun sum (vararg args: kotlin.Int): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null + fn: FUNCTION_REFERENCE 'public final fun sum (vararg args: kotlin.Int): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= FUN name:testArrayAsVararg visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useArray (fn: kotlin.Function1, kotlin.Int>): kotlin.Unit declared in ' type=kotlin.Unit origin=null - fn: FUNCTION_REFERENCE 'public final fun nsum (vararg args: kotlin.Number): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null + fn: FUNCTION_REFERENCE 'public final fun nsum (vararg args: kotlin.Number): kotlin.Int declared in ' type=kotlin.reflect.KFunction1, kotlin.Int> origin=null reflectionTarget= FUN name:testArrayAndDefaults visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun useStringArray (fn: kotlin.Function1, kotlin.Unit>): kotlin.Unit declared in ' type=kotlin.Unit origin=null fn: BLOCK type=kotlin.reflect.KFunction1, kotlin.Unit> origin=null - FUN name:zap visibility:local modality:FINAL <> (p0:kotlin.Array) returnType:kotlin.Unit - VALUE_PARAMETER name:p0 index:0 type:kotlin.Array + FUN ADAPTER_FOR_CALLABLE_REFERENCE name:zap visibility:local modality:FINAL <> (p0:kotlin.Array) returnType:kotlin.Unit + VALUE_PARAMETER ADAPTER_PARAMETER_FOR_CALLABLE_REFERENCE name:p0 index:0 type:kotlin.Array BLOCK_BODY CALL 'public final fun zap (vararg b: kotlin.String, k: kotlin.Int): kotlin.Unit declared in ' type=kotlin.Unit origin=null b: VARARG type=kotlin.Array varargElementType=kotlin.String SPREAD_ELEMENT GET_VAR 'p0: kotlin.Array declared in .testArrayAndDefaults.zap' type=kotlin.Array origin=null - FUNCTION_REFERENCE 'local final fun zap (p0: kotlin.Array): kotlin.Unit declared in .testArrayAndDefaults' type=kotlin.reflect.KFunction1, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'local final fun zap (p0: kotlin.Array): kotlin.Unit declared in .testArrayAndDefaults' type=kotlin.reflect.KFunction1, kotlin.Unit> origin=null reflectionTarget=null diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.txt new file mode 100644 index 00000000000..dc4339cd8f5 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.fir.txt @@ -0,0 +1,46 @@ +FILE fqName: fileName:/samConversionOnCallableReference.kt + CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KRunnable + FUN name:run visibility:public modality:ABSTRACT <> ($this:.KRunnable) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.KRunnable + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:foo0 visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + FUN name:foo1 visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo1 (xs: kotlin.IntArray): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + FUN name:use visibility:public modality:FINAL <> (r:.KRunnable) returnType:kotlin.Unit + VALUE_PARAMETER name:r index:0 type:.KRunnable + BLOCK_BODY + FUN name:testSamConstructor visibility:public modality:FINAL <> () returnType:.KRunnable + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testSamConstructor (): .KRunnable declared in ' + CALL 'public final fun KRunnable (block: kotlin.Function0): .KRunnable declared in ' type=.KRunnable origin=null + block: FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + FUN name:testSamCosntructorOnAdapted visibility:public modality:FINAL <> () returnType:IrErrorType + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testSamCosntructorOnAdapted (): IrErrorType declared in ' + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUNCTION_REFERENCE 'public final fun foo1 (xs: kotlin.IntArray): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= + FUN name:testSamConversion visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun use (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r: FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + FUN name:testSamConversionOnAdapted visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + ERROR_CALL 'Unresolved reference: #' type=IrErrorType + FUNCTION_REFERENCE 'public final fun foo1 (xs: kotlin.IntArray): kotlin.Int declared in ' type=kotlin.reflect.KFunction1 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt new file mode 100644 index 00000000000..bdbd5c12bc4 --- /dev/null +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions +fun interface KRunnable { + fun run() +} + +fun foo0() {} +fun foo1(vararg xs: Int): Int = 1 + +fun use(r: KRunnable) {} + +fun testSamConstructor() = + KRunnable(::foo0) + +// TODO should use an adapter function +fun testSamCosntructorOnAdapted() = + KRunnable(::foo1) + +fun testSamConversion() { + use(::foo0) +} + +// TODO should use an adapter function +fun testSamConversionOnAdapted() { + use(::foo1) +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt new file mode 100644 index 00000000000..fdf8029e62b --- /dev/null +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.txt @@ -0,0 +1,48 @@ +FILE fqName: fileName:/samConversionOnCallableReference.kt + CLASS INTERFACE name:KRunnable modality:ABSTRACT visibility:public [fun] superTypes:[kotlin.Any] + $this: VALUE_PARAMETER INSTANCE_RECEIVER name: type:.KRunnable + FUN name:run visibility:public modality:ABSTRACT <> ($this:.KRunnable) returnType:kotlin.Unit + $this: VALUE_PARAMETER name: type:.KRunnable + 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 + $this: VALUE_PARAMETER name: type:kotlin.Any + VALUE_PARAMETER name:other index:0 type:kotlin.Any? + FUN FAKE_OVERRIDE name:hashCode visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.Int [fake_override] + overridden: + public open fun hashCode (): kotlin.Int declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN FAKE_OVERRIDE name:toString visibility:public modality:OPEN <> ($this:kotlin.Any) returnType:kotlin.String [fake_override] + overridden: + public open fun toString (): kotlin.String declared in kotlin.Any + $this: VALUE_PARAMETER name: type:kotlin.Any + FUN name:foo0 visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + FUN name:foo1 visibility:public modality:FINAL <> (xs:kotlin.IntArray) returnType:kotlin.Int + VALUE_PARAMETER name:xs index:0 type:kotlin.IntArray varargElementType:kotlin.Int [vararg] + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in ' + CONST Int type=kotlin.Int value=1 + FUN name:use visibility:public modality:FINAL <> (r:.KRunnable) returnType:kotlin.Unit + VALUE_PARAMETER name:r index:0 type:.KRunnable + BLOCK_BODY + FUN name:testSamConstructor visibility:public modality:FINAL <> () returnType:.KRunnable + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testSamConstructor (): .KRunnable declared in ' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + FUN name:testSamCosntructorOnAdapted visibility:public modality:FINAL <> () returnType:.KRunnable + BLOCK_BODY + RETURN type=kotlin.Nothing from='public final fun testSamCosntructorOnAdapted (): .KRunnable declared in ' + TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + FUNCTION_REFERENCE 'public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + FUN name:testSamConversion visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun use (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + FUNCTION_REFERENCE 'public final fun foo0 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + FUN name:testSamConversionOnAdapted visibility:public modality:FINAL <> () returnType:kotlin.Unit + BLOCK_BODY + CALL 'public final fun use (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null + r: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable + FUNCTION_REFERENCE 'public final fun foo1 (vararg xs: kotlin.Int): kotlin.Int declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.txt index 6febaf26279..24003b20dcc 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.fir.txt @@ -110,4 +110,4 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt FUN name:test9 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null - r: FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + r: FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.txt b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.txt index 3a6b016ee1d..445044495c5 100644 --- a/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.txt +++ b/compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.txt @@ -128,4 +128,4 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BLOCK_BODY CALL 'public final fun run1 (r: .KRunnable): kotlin.Unit declared in ' type=kotlin.Unit origin=null r: TYPE_OP type=.KRunnable origin=SAM_CONVERSION typeOperand=.KRunnable - FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt b/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt index 29e33db23d3..77cacc55384 100644 --- a/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt +++ b/compiler/testData/ir/irText/expressions/reflectionLiterals.fir.txt @@ -55,7 +55,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.reflect.KFunction1<.A, kotlin.Unit> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A, kotlin.Unit> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<.A, kotlin.Unit> correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY @@ -64,7 +64,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test4 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.reflect.KFunction0<.A> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public constructor () [primary] declared in .A' type=kotlin.reflect.KFunction0<.A> origin=null + FUNCTION_REFERENCE 'public constructor () [primary] declared in .A' type=kotlin.reflect.KFunction0<.A> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0<.A> correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val] BLOCK_BODY @@ -73,7 +73,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test5 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test5 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test5 visibility:public modality:FINAL [val] BLOCK_BODY @@ -82,7 +82,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test6 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test6 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun bar (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun bar (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test6 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/reflectionLiterals.txt b/compiler/testData/ir/irText/expressions/reflectionLiterals.txt index 6e509012cfc..193abd412cb 100644 --- a/compiler/testData/ir/irText/expressions/reflectionLiterals.txt +++ b/compiler/testData/ir/irText/expressions/reflectionLiterals.txt @@ -54,7 +54,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:kotlin.reflect.KFunction1<.A, kotlin.Unit> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A, kotlin.Unit> origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction1<.A, kotlin.Unit> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction1<.A, kotlin.Unit> correspondingProperty: PROPERTY name:test3 visibility:public modality:FINAL [val] BLOCK_BODY @@ -63,7 +63,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test4 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test4 type:kotlin.reflect.KFunction0<.A> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public constructor () [primary] declared in .A' type=kotlin.reflect.KFunction0<.A> origin=null + FUNCTION_REFERENCE 'public constructor () [primary] declared in .A' type=kotlin.reflect.KFunction0<.A> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0<.A> correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val] BLOCK_BODY @@ -72,7 +72,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test5 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test5 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in .A' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .A' type=.A origin=null FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test5 visibility:public modality:FINAL [val] @@ -82,7 +82,7 @@ FILE fqName: fileName:/reflectionLiterals.kt PROPERTY name:test6 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test6 type:kotlin.reflect.KFunction0 visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public final fun bar (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun bar (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.reflect.KFunction0 correspondingProperty: PROPERTY name:test6 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt index a937c757259..e0224913459 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.fir.txt @@ -19,7 +19,7 @@ FILE fqName: fileName:/samConstructors.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (): java.lang.Runnable declared in ' CALL 'public final fun Runnable (block: kotlin.Function0): java.lang.Runnable declared in java.lang' type=java.lang.Runnable origin=null - block: FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + block: FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:test4 visibility:public modality:FINAL <> () returnType:java.util.Comparator BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (): java.util.Comparator declared in ' diff --git a/compiler/testData/ir/irText/expressions/sam/samConstructors.txt b/compiler/testData/ir/irText/expressions/sam/samConstructors.txt index 7e2dadf931a..099fe672dab 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConstructors.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConstructors.txt @@ -20,7 +20,7 @@ FILE fqName: fileName:/samConstructors.kt BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test3 (): java.lang.Runnable declared in ' TYPE_OP type=java.lang.Runnable origin=SAM_CONVERSION typeOperand=java.lang.Runnable - FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun foo (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:test4 visibility:public modality:FINAL <> () returnType:java.util.Comparator BLOCK_BODY RETURN type=kotlin.Nothing from='public final fun test4 (): java.util.Comparator declared in ' diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt index 608c83a1a80..6107d92d5df 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.fir.txt @@ -90,4 +90,4 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt BLOCK_BODY CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .J' type=.J origin=null - r: FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + r: FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt index 0f5bf3614fe..864ad89e6b5 100644 --- a/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt +++ b/compiler/testData/ir/irText/expressions/sam/samConversionsWithSmartCasts.txt @@ -115,4 +115,4 @@ FILE fqName: fileName:/samConversionsWithSmartCasts.kt CALL 'public open fun run1 (r: java.lang.Runnable?): kotlin.Unit declared in .J' type=kotlin.Unit origin=null $this: CONSTRUCTOR_CALL 'public constructor () [primary] declared in .J' type=.J origin=null r: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun test9 (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt b/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt index 7cd3d1fd57f..337e8f7be6c 100644 --- a/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt +++ b/compiler/testData/ir/irText/expressions/sam/samOperators.fir.txt @@ -6,29 +6,29 @@ FILE fqName: fileName:/samOperators.kt BLOCK_BODY CALL 'public open fun get (k: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: GET_VAR ': .J declared in .test1' type=.J origin=null - k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= CALL 'public open fun get (k: java.lang.Runnable?, m: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: GET_VAR ': .J declared in .test1' type=.J origin=null - k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null - m: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + m: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:test2 visibility:public modality:FINAL <> ($receiver:.J) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.J BLOCK_BODY CALL 'public open fun set (k: java.lang.Runnable?, v: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: GET_VAR ': .J declared in .test2' type=.J origin=null - k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null - v: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + v: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= CALL 'public open fun set (k: java.lang.Runnable?, m: java.lang.Runnable?, v: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: GET_VAR ': .J declared in .test2' type=.J origin=null - k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null - m: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null - v: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + k: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + m: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= + v: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:test3 visibility:public modality:FINAL <> ($receiver:.J) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.J BLOCK_BODY CALL 'public open fun plusAssign (i: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: GET_VAR ': .J declared in .test3' type=.J origin=null - i: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + i: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= CALL 'public open fun minusAssign (i: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null $this: GET_VAR ': .J declared in .test3' type=.J origin=null - i: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + i: FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/sam/samOperators.txt b/compiler/testData/ir/irText/expressions/sam/samOperators.txt index 7e65132ea8b..f6a453d0a4c 100644 --- a/compiler/testData/ir/irText/expressions/sam/samOperators.txt +++ b/compiler/testData/ir/irText/expressions/sam/samOperators.txt @@ -7,38 +7,38 @@ FILE fqName: fileName:/samOperators.kt CALL 'public open fun get (k: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=GET_ARRAY_ELEMENT $this: GET_VAR ': .J declared in .test1' type=.J origin=null k: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= CALL 'public open fun get (k: java.lang.Runnable?, m: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=GET_ARRAY_ELEMENT $this: GET_VAR ': .J declared in .test1' type=.J origin=null k: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= m: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:test2 visibility:public modality:FINAL <> ($receiver:.J) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.J BLOCK_BODY CALL 'public open fun set (k: java.lang.Runnable?, v: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=EQ $this: GET_VAR ': .J declared in .test2' type=.J origin=null k: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= v: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= CALL 'public open fun set (k: java.lang.Runnable?, m: java.lang.Runnable?, v: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=EQ $this: GET_VAR ': .J declared in .test2' type=.J origin=null k: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= m: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= v: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= FUN name:test3 visibility:public modality:FINAL <> ($receiver:.J) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:.J BLOCK_BODY CALL 'public open fun plusAssign (i: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=PLUSEQ $this: GET_VAR ': .J declared in .test3' type=.J origin=PLUSEQ i: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= CALL 'public open fun minusAssign (i: java.lang.Runnable?): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=MINUSEQ $this: GET_VAR ': .J declared in .test3' type=.J origin=MINUSEQ i: TYPE_OP type=java.lang.Runnable? origin=SAM_CONVERSION typeOperand=java.lang.Runnable? - FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null + FUNCTION_REFERENCE 'public final fun f (): kotlin.Unit declared in ' type=kotlin.reflect.KFunction0 origin=null reflectionTarget= diff --git a/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.fir.txt b/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.fir.txt index 6ab74fb876d..107fa580e3f 100644 --- a/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.fir.txt +++ b/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.fir.txt @@ -61,7 +61,7 @@ FILE fqName: fileName:/typeAliasConstructorReference.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Function1.C> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .C' type=kotlin.reflect.KFunction1.C> origin=null + FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .C' type=kotlin.reflect.KFunction1.C> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1.C> correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -70,7 +70,7 @@ FILE fqName: fileName:/typeAliasConstructorReference.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function1.Host.Nested> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .Host.Nested' type=kotlin.reflect.KFunction1.Host.Nested> origin=null + FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .Host.Nested' type=kotlin.reflect.KFunction1.Host.Nested> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1.Host.Nested> correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.txt b/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.txt index 12e89558828..1e31dd56b26 100644 --- a/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.txt +++ b/compiler/testData/ir/irText/expressions/typeAliasConstructorReference.txt @@ -63,7 +63,7 @@ FILE fqName: fileName:/typeAliasConstructorReference.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:kotlin.Function1.C{ .CA }> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .C' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, .C{ .CA }> origin=null + FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .C' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, .C{ .CA }> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1.C{ .CA }> correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -72,7 +72,7 @@ FILE fqName: fileName:/typeAliasConstructorReference.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:kotlin.Function1.Host.Nested{ .NA }> visibility:private [final,static] EXPRESSION_BODY - FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .Host.Nested' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, .Host.Nested{ .NA }> origin=null + FUNCTION_REFERENCE 'public constructor (x: kotlin.Int) [primary] declared in .Host.Nested' type=kotlin.reflect.KFunction1<@[ParameterName(name = 'x')] kotlin.Int, .Host.Nested{ .NA }> origin=null reflectionTarget= FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:kotlin.Function1.Host.Nested{ .NA }> correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java index e6f9bc00f14..ee6e2a05b5e 100644 --- a/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/ir/IrTextTestCaseGenerated.java @@ -1479,6 +1479,11 @@ public class IrTextTestCaseGenerated extends AbstractIrTextTestCase { runTest("compiler/testData/ir/irText/expressions/funInterface/partialSam.kt"); } + @TestMetadata("samConversionOnCallableReference.kt") + public void testSamConversionOnCallableReference() throws Exception { + runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionOnCallableReference.kt"); + } + @TestMetadata("samConversionsWithSmartCasts.kt") public void testSamConversionsWithSmartCasts() throws Exception { runTest("compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt"); diff --git a/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinAbiVersion.kt b/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinAbiVersion.kt index cf77c0eaf00..bca93ebff52 100644 --- a/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinAbiVersion.kt +++ b/compiler/util-klib/src/org/jetbrains/kotlin/library/KotlinAbiVersion.kt @@ -22,7 +22,7 @@ fun String.parseKonanAbiVersion(): KotlinAbiVersion { data class KotlinAbiVersion(val version: Int) { companion object { - val CURRENT = KotlinAbiVersion(24) + val CURRENT = KotlinAbiVersion(25) } override fun toString() = "$version"