diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt index 86cf3d7717d..1dee4c228fd 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/AddContinuationLowering.kt @@ -69,7 +69,7 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower // The only references not yet transformed into objects are inline lambdas; the continuation // for those will be taken from the inline functions they are passed to, not the enclosing scope. return transformed.retargetToSuspendView(context, null) { - IrFunctionReferenceImpl(startOffset, endOffset, type, it, typeArgumentsCount, reflectionTarget, origin) + IrFunctionReferenceImpl.fromSymbolOwner(startOffset, endOffset, type, it, typeArgumentsCount, reflectionTarget, origin) } } 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 577a8f709bc..9afbdc48382 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 @@ -110,7 +110,7 @@ private class InlineCallableReferenceToLambdaTransformer( } +function - +IrFunctionReferenceImpl( + +IrFunctionReferenceImpl.fromSymbolOwner( expression.startOffset, expression.endOffset, field.type, @@ -190,7 +190,7 @@ private class InlineCallableReferenceToLambdaTransformer( } +function - +IrFunctionReferenceImpl( + +IrFunctionReferenceImpl.fromSymbolOwner( expression.startOffset, expression.endOffset, function.returnType, 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 000108733d4..33538836587 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 @@ -113,7 +113,8 @@ private class PropertyReferenceLowering(val context: JvmBackendContext) : IrElem // Internal underlying vals of inline classes have no getter method getter.owner.isInlineClassFieldGetter && getter.owner.visibility == DescriptorVisibilities.INTERNAL val origin = if (needsDummySignature) InlineClassAbi.UNMANGLED_FUNCTION_REFERENCE else null - val reference = IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, expression.type, getter, 0, getter, origin) + val reference = + IrFunctionReferenceImpl.fromSymbolOwner(UNDEFINED_OFFSET, UNDEFINED_OFFSET, expression.type, getter, 0, getter, origin) return irCall(signatureStringIntrinsic).apply { putValueArgument(0, reference) } } 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 2256175e524..beb3241b397 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 @@ -492,7 +492,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St typeArguments: Map?, origin: IrStatementOrigin? ): IrFunctionReference = - IrFunctionReferenceImpl( + IrFunctionReferenceImpl.fromSymbolDescriptor( startOffset, endOffset, type.toIrType(), symbol, typeArgumentsCount = descriptor.typeParametersCount, 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 22c0ff4b523..636714b1427 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 @@ -36,25 +36,6 @@ class IrFunctionReferenceImpl( override val reflectionTarget: IrFunctionSymbol? = symbol, override val origin: IrStatementOrigin? = null, ) : IrFunctionReference(typeArgumentsCount) { - @ObsoleteDescriptorBasedAPI - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrFunctionSymbol, - typeArgumentsCount: Int, - reflectionTarget: IrFunctionSymbol?, - origin: IrStatementOrigin? = null - ) : this( - startOffset, endOffset, - type, - symbol, - typeArgumentsCount, - symbol.descriptor.valueParameters.size, - reflectionTarget, - origin - ) - override val referencedName: Name get() = symbol.owner.name @@ -92,4 +73,43 @@ class IrFunctionReferenceImpl( argumentsByParameterIndex[i] = irExpression?.transform(transformer, data) } } + + companion object { + @ObsoleteDescriptorBasedAPI + fun fromSymbolDescriptor( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrFunctionSymbol, + typeArgumentsCount: Int, + reflectionTarget: IrFunctionSymbol?, + origin: IrStatementOrigin? = null + ) = IrFunctionReferenceImpl( + startOffset, endOffset, + type, + symbol, + typeArgumentsCount, + symbol.descriptor.valueParameters.size, + reflectionTarget, + origin + ) + + fun fromSymbolOwner( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrFunctionSymbol, + typeArgumentsCount: Int, + reflectionTarget: IrFunctionSymbol?, + origin: IrStatementOrigin? = null + ) = IrFunctionReferenceImpl( + startOffset, endOffset, + type, + symbol, + typeArgumentsCount, + symbol.owner.valueParameters.size, + reflectionTarget, + origin + ) + } }