From b28c85f5eaa98199d45ff717392ae8e484f29911 Mon Sep 17 00:00:00 2001 From: Georgy Bronnikov Date: Wed, 14 Oct 2020 12:31:00 +0300 Subject: [PATCH] IR: IrCall.fromSymbolDescriptor --- .../jvm/descriptors/SharedVariablesManager.kt | 2 +- .../kotlin/backend/jvm/ir/IrUtils.kt | 2 +- .../jvm/lower/AddContinuationLowering.kt | 5 +- .../jvm/lower/GenerateMultifileFacades.kt | 2 +- .../backend/jvm/lower/InterfaceLowering.kt | 4 +- .../jvm/lower/JvmInlineClassLowering.kt | 2 +- .../jvm/lower/JvmOptimizationLowering.kt | 4 +- .../lower/JvmOverloadsAnnotationLowering.kt | 2 +- .../JvmStandardLibraryBuiltInsLowering.kt | 4 +- .../jvm/lower/PolymorphicSignatureLowering.kt | 5 +- ...eplaceKFunctionInvokeWithFunctionInvoke.kt | 2 +- .../backend/jvm/lower/ResolveInlineCalls.kt | 1 + .../jvm/lower/SyntheticAccessorLowering.kt | 10 ++-- .../BranchingExpressionGenerator.kt | 2 +- .../kotlin/psi2ir/generators/CallGenerator.kt | 10 ++-- .../psi2ir/generators/ClassGenerator.kt | 2 +- .../generators/OperatorExpressionGenerator.kt | 6 +- .../ReflectionReferencesGenerator.kt | 2 +- .../DelegatedLocalPropertyLValue.kt | 4 +- .../kotlin/ir/expressions/impl/IrCallImpl.kt | 56 ++++++++++--------- .../synthetic/codegen/AndroidIrExtension.kt | 2 +- 21 files changed, 69 insertions(+), 60 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt index fee45604ad5..fa9a10c23ad 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/SharedVariablesManager.kt @@ -127,7 +127,7 @@ class JvmSharedVariablesManager( } private fun unsafeCoerce(value: IrExpression, from: IrType, to: IrType): IrExpression = - IrCallImpl(value.startOffset, value.endOffset, to, symbols.unsafeCoerceIntrinsic).apply { + IrCallImpl.fromSymbolOwner(value.startOffset, value.endOffset, to, symbols.unsafeCoerceIntrinsic).apply { putTypeArgument(0, from) putTypeArgument(1, to) putValueArgument(0, value) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt index e8c8a4cef50..afa12be2cf5 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/ir/IrUtils.kt @@ -124,7 +124,7 @@ fun IrType.defaultValue(startOffset: Int, endOffset: Int, context: JvmBackendCon val underlyingType = unboxInlineClass() val defaultValueForUnderlyingType = IrConstImpl.defaultValueForType(startOffset, endOffset, underlyingType) - return IrCallImpl(startOffset, endOffset, this, context.ir.symbols.unsafeCoerceIntrinsic).also { + return IrCallImpl.fromSymbolOwner(startOffset, endOffset, this, context.ir.symbols.unsafeCoerceIntrinsic).also { it.putTypeArgument(0, underlyingType) // from it.putTypeArgument(1, this) // to it.putValueArgument(0, defaultValueForUnderlyingType) 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 436510ef336..86cf3d7717d 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 @@ -76,7 +76,10 @@ private class AddContinuationLowering(context: JvmBackendContext) : SuspendLower override fun visitCall(expression: IrCall): IrExpression { val transformed = super.visitCall(expression) as IrCall return transformed.retargetToSuspendView(context, functionStack.peek() ?: return transformed) { - IrCallImpl(startOffset, endOffset, type, it, origin, superQualifierSymbol) + IrCallImpl.fromSymbolOwner( + startOffset, endOffset, type, it, + origin = origin, superQualifierSymbol = superQualifierSymbol + ) } } }) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt index 3f35f36d497..cf56cd002d8 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/GenerateMultifileFacades.kt @@ -269,7 +269,7 @@ private class UpdateFunctionCallSites( return expression.run { // TODO: deduplicate this with ReplaceKFunctionInvokeWithFunctionInvoke - IrCallImpl(startOffset, endOffset, type, newFunction.symbol).apply { + IrCallImpl.fromSymbolOwner(startOffset, endOffset, type, newFunction.symbol).apply { copyTypeArgumentsFrom(expression) extensionReceiver = expression.extensionReceiver?.transform(this@UpdateFunctionCallSites, null) for (i in 0 until valueArgumentsCount) { 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 2b35c8796ec..1331283d2b1 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 @@ -193,7 +193,7 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran // Bridge from static to static method - simply fill the function arguments to the parameters. // By nature of the generation of both source and target of bridge, they line up. private fun IrFunction.bridgeToStatic(callTarget: IrSimpleFunction) { - body = IrExpressionBodyImpl(IrCallImpl(startOffset, endOffset, returnType, callTarget.symbol).also { call -> + body = IrExpressionBodyImpl(IrCallImpl.fromSymbolOwner(startOffset, endOffset, returnType, callTarget.symbol).also { call -> callTarget.typeParameters.forEachIndexed { i, _ -> call.putTypeArgument(i, createPlaceholderAnyNType(context.irBuiltIns)) @@ -209,7 +209,7 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran // be shifted in presence of dispatch and extension receiver. private fun IrFunction.bridgeViaAccessorTo(callTarget: IrSimpleFunction) { body = IrExpressionBodyImpl( - IrCallImpl( + IrCallImpl.fromSymbolOwner( startOffset, endOffset, returnType, 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 12ef0fd8ab0..922e83a409e 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 @@ -302,7 +302,7 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F } private fun coerceInlineClasses(argument: IrExpression, from: IrType, to: IrType) = - IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, to, context.ir.symbols.unsafeCoerceIntrinsic).apply { + IrCallImpl.fromSymbolOwner(UNDEFINED_OFFSET, UNDEFINED_OFFSET, to, context.ir.symbols.unsafeCoerceIntrinsic).apply { putTypeArgument(0, from) putTypeArgument(1, to) putValueArgument(0, argument) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOptimizationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOptimizationLowering.kt index 8650b71014f..e752ba19413 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOptimizationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOptimizationLowering.kt @@ -204,7 +204,7 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass "Failing expression: ${expression.dump()}" } // Replace conjunction condition with intrinsic "and" function call - return IrCallImpl( + return IrCallImpl.fromSymbolOwner( expression.startOffset, expression.endOffset, context.irBuiltIns.booleanType, @@ -225,7 +225,7 @@ class JvmOptimizationLowering(val context: JvmBackendContext) : FileLoweringPass "and an 'if true then b' body on its second branch. " + "Failing expression: ${expression.dump()}" } - return IrCallImpl( + return IrCallImpl.fromSymbolOwner( expression.startOffset, expression.endOffset, context.irBuiltIns.booleanType, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt index c2ff837bc18..0a753472d7a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt @@ -60,7 +60,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C is IrConstructor -> IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol) is IrSimpleFunction -> - IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol) + IrCallImpl.fromSymbolOwner(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol) else -> error("unknown function kind: ${target.render()}") } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStandardLibraryBuiltInsLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStandardLibraryBuiltInsLowering.kt index 5e4411b1fa8..5d3a399f81e 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStandardLibraryBuiltInsLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmStandardLibraryBuiltInsLowering.kt @@ -60,7 +60,7 @@ class JvmStandardLibraryBuiltInsLowering(val context: JvmBackendContext) : FileL // Originals are so far only instance methods, and the replacements are // statics, so we copy dispatch receivers to a value argument if needed. private fun IrCall.replaceWithCallTo(replacement: IrSimpleFunctionSymbol) = - IrCallImpl( + IrCallImpl.fromSymbolOwner( startOffset, endOffset, type, @@ -77,7 +77,7 @@ class JvmStandardLibraryBuiltInsLowering(val context: JvmBackendContext) : FileL } private fun IrExpression.coerceTo(target: IrType): IrExpression = - IrCallImpl( + IrCallImpl.fromSymbolOwner( startOffset, endOffset, target, diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PolymorphicSignatureLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PolymorphicSignatureLowering.kt index f43cc24a7ff..059b324f0b2 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PolymorphicSignatureLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/PolymorphicSignatureLowering.kt @@ -77,7 +77,10 @@ class PolymorphicSignatureLowering(val context: JvmBackendContext) : IrElementTr addValueParameter("\$$i", value.type, JvmLoweredDeclarationOrigin.POLYMORPHIC_SIGNATURE_INSTANTIATION) } } - return IrCallImpl(startOffset, endOffset, fakeFunction.returnType, fakeFunction.symbol, origin, superQualifierSymbol).apply { + return IrCallImpl.fromSymbolOwner( + startOffset, endOffset, fakeFunction.returnType, fakeFunction.symbol, + origin = origin, superQualifierSymbol = superQualifierSymbol + ).apply { copyTypeArgumentsFrom(this@transform) dispatchReceiver = this@transform.dispatchReceiver extensionReceiver = this@transform.extensionReceiver diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt index e5ad1541e66..14b22076bfe 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ReplaceKFunctionInvokeWithFunctionInvoke.kt @@ -50,7 +50,7 @@ private class ReplaceKFunctionInvokeWithFunctionInvoke : FileLoweringPass, IrEle // The single overridden function of KFunction{n}.invoke must be Function{n}.invoke. val newCallee = callee.overriddenSymbols.single() return expression.run { - IrCallImpl(startOffset, endOffset, type, newCallee).apply { + IrCallImpl.fromSymbolOwner(startOffset, endOffset, type, newCallee).apply { copyTypeArgumentsFrom(expression) dispatchReceiver = expression.dispatchReceiver?.transform(this@ReplaceKFunctionInvokeWithFunctionInvoke, null)?.let { val newType = newCallee.owner.parentAsClass.defaultType diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ResolveInlineCalls.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ResolveInlineCalls.kt index 36725d4b70a..a9a12d9521a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ResolveInlineCalls.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/ResolveInlineCalls.kt @@ -49,6 +49,7 @@ class ResolveInlineCalls(val context: JvmBackendContext) : IrElementTransformerV type, resolved.symbol, expression.typeArgumentsCount, + expression.valueArgumentsCount, expression.origin, superQualifierSymbol ).apply { 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 5e662b16fd9..0c083311df8 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 @@ -314,7 +314,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle } private fun createSimpleFunctionCall(accessor: IrFunction, targetSymbol: IrSimpleFunctionSymbol, superQualifierSymbol: IrClassSymbol?) = - IrCallImpl( + IrCallImpl.fromSymbolOwner( accessor.startOffset, accessor.endOffset, accessor.returnType, @@ -412,11 +412,11 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle accessorSymbol: IrFunctionSymbol ): IrFunctionAccessExpression { val newExpression = when (oldExpression) { - is IrCall -> IrCallImpl( + is IrCall -> IrCallImpl.fromSymbolOwner( oldExpression.startOffset, oldExpression.endOffset, oldExpression.type, accessorSymbol as IrSimpleFunctionSymbol, oldExpression.typeArgumentsCount, - oldExpression.origin + origin = oldExpression.origin ) is IrDelegatingConstructorCall -> IrDelegatingConstructorCallImpl( oldExpression.startOffset, oldExpression.endOffset, @@ -457,7 +457,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle val call = IrCallImpl( oldExpression.startOffset, oldExpression.endOffset, oldExpression.type, - accessorSymbol, 0, + accessorSymbol, 0, accessorSymbol.owner.valueParameters.size, oldExpression.origin ) oldExpression.receiver?.let { @@ -473,7 +473,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle val call = IrCallImpl( oldExpression.startOffset, oldExpression.endOffset, oldExpression.type, - accessorSymbol, 0, + accessorSymbol, 0, accessorSymbol.owner.valueParameters.size, oldExpression.origin ) oldExpression.receiver?.let { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt index 90614436fd3..26d1d0de2d1 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BranchingExpressionGenerator.kt @@ -143,7 +143,7 @@ class BranchingExpressionGenerator(statementGenerator: StatementGenerator) : Sta val isExhaustive = whenExpression.isExhaustiveWhen() if (isExhaustive) { - val call = IrCallImpl( + val call = IrCallImpl.fromSymbolDescriptor( UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.nothingType, context.irBuiltIns.noWhenBranchMatchedExceptionSymbol diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt index f1897139269..11ef47b077a 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/CallGenerator.kt @@ -122,8 +122,8 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator if (descriptor is LocalVariableDescriptor && descriptor.isDelegated) { val getterDescriptor = descriptor.getter!! val getterSymbol = context.symbolTable.referenceSimpleFunction(getterDescriptor.original) - IrCallImpl( - startOffset, endOffset, descriptor.type.toIrType(), getterSymbol, origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY + IrCallImpl.fromSymbolDescriptor( + startOffset, endOffset, descriptor.type.toIrType(), getterSymbol, origin = origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY ).apply { context.callToSubstitutedDescriptorMap[this] = getterDescriptor putTypeArguments(typeArguments) { it.toIrType() } @@ -333,12 +333,12 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator } } else { val originalSymbol = context.symbolTable.referenceSimpleFunction(functionDescriptor.original) - IrCallImpl( + IrCallImpl.fromSymbolDescriptor( startOffset, endOffset, irType, originalSymbol, - origin, - call.superQualifier?.let { context.symbolTable.referenceClass(it) } + origin = origin, + superQualifierSymbol = call.superQualifier?.let { context.symbolTable.referenceClass(it) } ).run { context.callToSubstitutedDescriptorMap[this] = functionDescriptor putTypeArguments(call.typeArguments) { it.toIrType() } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt index 3d20df30936..e639a49bc03 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ClassGenerator.kt @@ -334,7 +334,7 @@ class ClassGenerator( val delegateToSymbol = context.symbolTable.referenceSimpleFunction(delegateToDescriptor.original) - val irCall = IrCallImpl( + val irCall = IrCallImpl.fromSymbolDescriptor( startOffset, endOffset, returnType.toIrType(), delegateToSymbol, diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt index 271bc57a357..9da6c50a61c 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/OperatorExpressionGenerator.kt @@ -414,7 +414,7 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat receiver: IrExpression ): IrExpression { val originalSymbol = context.symbolTable.referenceSimpleFunction(functionDescriptor.original) - return IrCallImpl( + return IrCallImpl.fromSymbolDescriptor( startOffset, endOffset, functionDescriptor.returnType!!.toIrType(), @@ -508,11 +508,11 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat ) ?: throw AssertionError("Substitution failed for $checkNotNull: T=$argumentType") val checkNotNullSymbol = context.irBuiltIns.checkNotNullSymbol - return IrCallImpl( + return IrCallImpl.fromSymbolDescriptor( ktOperator.startOffsetSkippingComments, ktOperator.endOffset, expressionType.toIrType(), checkNotNullSymbol, - origin + origin = origin ).apply { context.callToSubstitutedDescriptorMap[this] = checkNotNullSubstituted putTypeArgument(0, argumentType.toIrType().makeNotNull()) 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 a540983e706..2256175e524 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 @@ -202,7 +202,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St is IrConstructorSymbol -> IrConstructorCallImpl.fromSymbolDescriptor(startOffset, endOffset, irType, adapteeSymbol) is IrSimpleFunctionSymbol -> - IrCallImpl(startOffset, endOffset, irType, adapteeSymbol, origin = null, superQualifierSymbol = null) + IrCallImpl.fromSymbolDescriptor(startOffset, endOffset, irType, adapteeSymbol) else -> error("Unknown symbol kind $adapteeSymbol") } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt index 4c7ecbb3b20..a4d64ee4a4d 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/DelegatedLocalPropertyLValue.kt @@ -36,10 +36,10 @@ class DelegatedLocalPropertyLValue( AssignmentReceiver { override fun load(): IrExpression = - IrCallImpl(startOffset, endOffset, type, getterSymbol!!, origin) + IrCallImpl.fromSymbolDescriptor(startOffset, endOffset, type, getterSymbol!!, origin = origin) override fun store(irExpression: IrExpression): IrExpression = - IrCallImpl(startOffset, endOffset, context.irBuiltIns.unitType, setterSymbol!!, origin).apply { + IrCallImpl.fromSymbolDescriptor(startOffset, endOffset, context.irBuiltIns.unitType, setterSymbol!!, origin = origin).apply { putValueArgument(0, irExpression) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt index 0aea7e2ab6d..e065bd53370 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrCallImpl.kt @@ -43,33 +43,35 @@ class IrCallImpl( } } - @ObsoleteDescriptorBasedAPI - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - origin: IrStatementOrigin? = null, - superQualifierSymbol: IrClassSymbol? = null - ) : this( - startOffset, endOffset, type, symbol, symbol.descriptor.typeParametersCount, symbol.descriptor.valueParameters.size, - origin, superQualifierSymbol - ) - - @ObsoleteDescriptorBasedAPI - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrSimpleFunctionSymbol, - typeArgumentsCount: Int, - origin: IrStatementOrigin? = null, - superQualifierSymbol: IrClassSymbol? = null - ) : this( - startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size, - origin, superQualifierSymbol - ) - override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitCall(this, data) + + companion object { + @ObsoleteDescriptorBasedAPI + fun fromSymbolDescriptor( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrSimpleFunctionSymbol, + typeArgumentsCount: Int = symbol.descriptor.typeParametersCount, + valueArgumentsCount: Int = symbol.descriptor.valueParameters.size, + origin: IrStatementOrigin? = null, + superQualifierSymbol: IrClassSymbol? = null, + ) = IrCallImpl( + startOffset, endOffset, type, symbol, typeArgumentsCount, valueArgumentsCount, origin, superQualifierSymbol + ) + + fun fromSymbolOwner( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrSimpleFunctionSymbol, + typeArgumentsCount: Int = symbol.owner.typeParameters.size, + valueArgumentsCount: Int = symbol.owner.valueParameters.size, + origin: IrStatementOrigin? = null, + superQualifierSymbol: IrClassSymbol? = null, + ) = IrCallImpl( + startOffset, endOffset, type, symbol, typeArgumentsCount, valueArgumentsCount, origin, superQualifierSymbol + ) + } } diff --git a/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidIrExtension.kt b/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidIrExtension.kt index eab35a39547..7b6ee95706b 100644 --- a/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidIrExtension.kt +++ b/plugins/android-extensions/android-extensions-compiler/src/org/jetbrains/kotlin/android/synthetic/codegen/AndroidIrExtension.kt @@ -220,7 +220,7 @@ private fun FqName.child(name: String) = child(Name.identifier(name)) @ObsoleteDescriptorBasedAPI private fun IrSimpleFunction.callWithRanges(source: IrExpression) = - IrCallImpl(source.startOffset, source.endOffset, returnType, symbol) + IrCallImpl.fromSymbolDescriptor(source.startOffset, source.endOffset, returnType, symbol) private val AndroidContainerType.fqName: FqName get() = FqName(internalClassName.replace("/", "."))