From ba373c67d7f9a6b76d18317a49e199e293771b82 Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Tue, 22 Oct 2019 16:38:57 +0300 Subject: [PATCH] [IR] Remove FunctionDescriptor from IrCall-like node's constructor interface --- .../kotlin/fir/backend/Fir2IrVisitor.kt | 7 +++--- .../kotlin/backend/common/ir/IrUtils.kt | 4 ++-- .../lower/DefaultArgumentStubGenerator.kt | 4 +--- .../common/lower/InnerClassesLowering.kt | 4 +--- .../common/lower/LocalDeclarationsLowering.kt | 6 ++--- .../ProvisionalFunctionExpressionLowering.kt | 3 +-- .../backend/common/lower/loops/Utils.kt | 4 ++-- .../kotlin/ir/backend/js/ir/IrBuilder.kt | 3 +-- .../js/lower/CallableReferenceLowering.kt | 1 - .../lower/JsDefaultArgumentStubGenerator.kt | 2 -- .../js/lower/PrivateMembersLowering.kt | 8 +++---- .../js/lower/ScriptRemoveReceiverLowering.kt | 2 -- .../backend/js/lower/SecondaryCtorLowering.kt | 2 +- .../ir/backend/js/lower/ThrowableLowering.kt | 11 ++-------- .../backend/jvm/lower/BridgeLowering.kt | 3 +-- .../backend/jvm/lower/EnumClassLowering.kt | 6 +---- .../lower/InlineCallableReferenceToLambda.kt | 5 +---- .../backend/jvm/lower/InterfaceLowering.kt | 1 - .../jvm/lower/JvmInlineClassLowering.kt | 5 ++--- .../lower/JvmOverloadsAnnotationLowering.kt | 2 +- .../jvm/lower/MainMethodGenerationLowering.kt | 3 --- .../jvm/lower/SyntheticAccessorLowering.kt | 20 ++++++----------- .../kotlin/psi2ir/generators/BodyGenerator.kt | 3 +-- .../kotlin/psi2ir/generators/CallGenerator.kt | 16 ++++++-------- .../psi2ir/generators/ClassGenerator.kt | 4 ++-- .../generators/DataClassMembersGenerator.kt | 2 +- .../generators/OperatorExpressionGenerator.kt | 15 +++++++------ .../ReflectionReferencesGenerator.kt | 7 +++--- .../DelegatedLocalPropertyLValue.kt | 5 ++--- .../psi2ir/intermediate/PropertyLValue.kt | 6 ++--- .../kotlin/ir/builders/ExpressionHelpers.kt | 22 +++++-------------- .../kotlin/ir/builders/Primitives.kt | 5 ++--- .../kotlin/ir/expressions/impl/IrCallImpl.kt | 20 ++++++++--------- .../expressions/impl/IrConstructorCallImpl.kt | 5 ++--- .../impl/IrDelegatingConstructorCallImpl.kt | 16 ++++---------- .../impl/IrFunctionReferenceImpl.kt | 6 ++--- .../impl/IrPropertyReferenceImpl.kt | 19 ++-------------- .../ir/util/DeepCopyIrTreeWithSymbols.kt | 4 ---- .../org/jetbrains/kotlin/ir/util/IrUtils.kt | 2 -- .../serialization/IrFileDeserializer.kt | 8 ++----- .../compiler/backend/ir/GeneratorHelpers.kt | 3 +-- .../backend/ir/SerializableIrGenerator.kt | 6 ++--- 42 files changed, 90 insertions(+), 190 deletions(-) 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 f63a2a28f87..afdd173866c 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 @@ -680,8 +680,7 @@ class Fir2IrVisitor( when { symbol is IrConstructorSymbol -> IrConstructorCallImpl.fromSymbolOwner(startOffset, endOffset, type, symbol) symbol is IrSimpleFunctionSymbol -> IrCallImpl( - startOffset, endOffset, type, symbol, symbol.descriptor, - origin = calleeReference.statementOrigin() + startOffset, endOffset, type, symbol, origin = calleeReference.statementOrigin() ) symbol is IrPropertySymbol && symbol.isBound -> { val getter = symbol.owner.getter @@ -827,7 +826,7 @@ class Fir2IrVisitor( is IrFunctionSymbol -> { IrFunctionReferenceImpl( startOffset, endOffset, type, symbol, - symbol.descriptor, 0 + 0 ) } else -> { @@ -904,7 +903,7 @@ class Fir2IrVisitor( listOf( anonymousClass, IrConstructorCallImpl.fromSymbolOwner( - startOffset, endOffset, anonymousClassType, anonymousClass.constructors.first().symbol + startOffset, endOffset, anonymousClassType, anonymousClass.constructors.first().symbol, anonymousClass.typeParameters.size ) ) ) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt index dbd727484c1..185c969b3f7 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/ir/IrUtils.kt @@ -86,8 +86,8 @@ fun IrClass.addSimpleDelegatingConstructor( listOf( IrDelegatingConstructorCallImpl( startOffset, endOffset, irBuiltIns.unitType, - superConstructor.symbol, superConstructor.descriptor, - 0, superConstructor.valueParameters.size + superConstructor.symbol, 0, + superConstructor.valueParameters.size ).apply { constructor.valueParameters.forEachIndexed { idx, parameter -> putValueArgument(idx, IrGetValueImpl(startOffset, endOffset, parameter.type, parameter.symbol)) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt index 1fac3767596..b3fbec2687a 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/DefaultArgumentStubGenerator.kt @@ -129,7 +129,7 @@ open class DefaultArgumentStubGenerator( startOffset = irFunction.startOffset, endOffset = irFunction.endOffset, type = context.irBuiltIns.unitType, - symbol = irFunction.symbol, descriptor = irFunction.symbol.descriptor, + symbol = irFunction.symbol, typeArgumentsCount = newIrFunction.parentAsClass.typeParameters.size + newIrFunction.typeParameters.size ).apply { passTypeArgumentsFrom(newIrFunction.parentAsClass) @@ -269,7 +269,6 @@ open class DefaultParameterInjector( endOffset = expression.endOffset, type = context.irBuiltIns.unitType, symbol = it as IrConstructorSymbol, - descriptor = it.descriptor, typeArgumentsCount = expression.typeArgumentsCount ) } @@ -311,7 +310,6 @@ open class DefaultParameterInjector( endOffset = expression.endOffset, type = expression.type, symbol = it, - descriptor = it.descriptor, typeArgumentsCount = expression.typeArgumentsCount, origin = DEFAULT_DISPATCH_CALL, superQualifierSymbol = expression.superQualifierSymbol 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 45e340e5d53..5077b5c3a1c 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 @@ -150,8 +150,7 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : FileLowe val newCallee = context.declarationFactory.getInnerClassConstructorWithOuterThisParameter(classConstructor) val newCall = IrDelegatingConstructorCallImpl( - expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee.symbol, newCallee.descriptor, - expression.typeArgumentsCount + expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee.symbol, expression.typeArgumentsCount ).apply { copyTypeArgumentsFrom(expression) } newCall.putValueArgument(0, dispatchReceiver) @@ -177,7 +176,6 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : FileLowe endOffset, type, newCallee.symbol, - newCallee.descriptor, typeArgumentsCount, 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 645d4a7b584..bbdddd02c05 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 @@ -283,7 +283,6 @@ class LocalDeclarationsLowering( expression.startOffset, expression.endOffset, context.irBuiltIns.unitType, newCallee.symbol, - newCallee.descriptor, expression.typeArgumentsCount ).also { it.fillArguments2(expression, newCallee) @@ -341,7 +340,6 @@ class LocalDeclarationsLowering( expression.startOffset, expression.endOffset, expression.type, // TODO functional type for transformed descriptor newCallee.symbol, - newCallee.descriptor, expression.typeArgumentsCount, expression.origin ).also { @@ -440,9 +438,9 @@ class LocalDeclarationsLowering( oldCall.startOffset, oldCall.endOffset, newCallee.returnType, newCallee.symbol, - newCallee.descriptor, oldCall.typeArgumentsCount, - oldCall.origin, oldCall.superQualifierSymbol + oldCall.origin, + oldCall.superQualifierSymbol ).also { it.copyTypeArgumentsFrom(oldCall) } 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 e7ab960fccd..b372358ed08 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,8 +37,7 @@ class ProvisionalFunctionExpressionLowering : function, IrFunctionReferenceImpl( startOffset, endOffset, type, - function.symbol, function.descriptor, 0, - origin + function.symbol, 0, origin ) ) ) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt index 854293cf82a..7627165db06 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/loops/Utils.kt @@ -44,7 +44,7 @@ internal fun IrExpression.negate(): IrExpression { it.name == OperatorNameConventions.UNARY_MINUS && it.valueParameters.isEmpty() } - IrCallImpl(startOffset, endOffset, type, unaryMinusFun.symbol, unaryMinusFun.descriptor).apply { + IrCallImpl(startOffset, endOffset, type, unaryMinusFun.symbol).apply { dispatchReceiver = this@negate } } @@ -62,7 +62,7 @@ internal fun IrExpression.decrement(): IrExpression { it.name == OperatorNameConventions.DEC && it.valueParameters.isEmpty() } - IrCallImpl(startOffset, endOffset, type, decFun.symbol, decFun.descriptor).apply { + IrCallImpl(startOffset, endOffset, type, decFun.symbol).apply { dispatchReceiver = this@decrement } } 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 6fe4dcd63d9..00e0ed13cdd 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 @@ -32,7 +32,6 @@ object JsIrBuilder { UNDEFINED_OFFSET, type ?: target.owner.returnType, target, - target.descriptor, target.descriptor.typeParametersCount, SYNTHESIZED_STATEMENT ).apply { @@ -186,7 +185,7 @@ object JsIrBuilder { IrCompositeImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, SYNTHESIZED_STATEMENT, statements) fun buildFunctionReference(type: IrType, symbol: IrFunctionSymbol) = - IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, symbol, symbol.descriptor, 0, null) + IrFunctionReferenceImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, type, symbol, 0, null) fun buildVar( type: IrType, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt index 82b6db6732e..503978f1c32 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/CallableReferenceLowering.kt @@ -92,7 +92,6 @@ class CallableReferenceLowering(val context: JsIrBackendContext) : FileLoweringP callable.startOffset, callable.endOffset, newTarget.symbol.owner.returnType, newTarget.symbol, - newTarget.symbol.descriptor, callable.origin ).apply { copyTypeArgumentsFrom(callable) 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 de97c383cd5..5996dad2fdb 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,7 +79,6 @@ class JsDefaultCallbackGenerator(val context: JsIrBackendContext): BodyLoweringP endOffset, context.irBuiltIns.anyType, originalFunction.symbol, - originalFunction.descriptor, 0, BIND_CALL ) @@ -91,7 +90,6 @@ class JsDefaultCallbackGenerator(val context: JsIrBackendContext): BodyLoweringP endOffset, context.irBuiltIns.anyType, context.intrinsics.jsBind.symbol, - context.intrinsics.jsBind.descriptor, BIND_CALL, superQualifierSymbol ) 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 d46c6d4595b..33dbd6f58b4 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 @@ -82,9 +82,8 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : FileLoweringPass IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type, - it.symbol, it.descriptor, - expression.typeArgumentsCount, expression.valueArgumentsCount, - expression.origin + it.symbol, expression.typeArgumentsCount, + expression.valueArgumentsCount, expression.origin ) } } ?: expression @@ -113,8 +112,7 @@ class PrivateMembersLowering(val context: JsIrBackendContext) : FileLoweringPass val newExpression = IrCallImpl( expression.startOffset, expression.endOffset, expression.type, - staticTarget.symbol, staticTarget.descriptor, - expression.typeArgumentsCount, + staticTarget.symbol, expression.typeArgumentsCount, expression.origin, expression.superQualifierSymbol ) 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 3af60c01490..be79c9325b5 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 @@ -75,7 +75,6 @@ private class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : type.annotations ), symbol, - descriptor, typeArgumentsCount, valueArgumentsCount, origin @@ -111,7 +110,6 @@ private class ScriptRemoveReceiverLowering(val context: CommonBackendContext) : type.annotations ), symbol, - descriptor, typeArgumentsCount, field, getter, diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt index 81f5660dd42..46881592c5f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/SecondaryCtorLowering.kt @@ -238,7 +238,7 @@ private class CallsiteRedirectionTransformer(context: JsIrBackendContext) : IrEl private fun replaceSecondaryConstructorWithFactoryFunction( call: IrFunctionAccessExpression, newTarget: IrSimpleFunctionSymbol - ) = IrCallImpl(call.startOffset, call.endOffset, call.type, newTarget, newTarget.descriptor, call.typeArgumentsCount).apply { + ) = IrCallImpl(call.startOffset, call.endOffset, call.type, newTarget, call.typeArgumentsCount).apply { copyTypeArgumentsFrom(call) diff --git a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt index 1b3ac75b13a..219e5f5aa7f 100644 --- a/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt +++ b/compiler/ir/backend.js/src/org/jetbrains/kotlin/ir/backend/js/lower/ThrowableLowering.kt @@ -6,23 +6,16 @@ package org.jetbrains.kotlin.ir.backend.js.lower import org.jetbrains.kotlin.backend.common.FileLoweringPass -import org.jetbrains.kotlin.backend.common.lower.callsSuper -import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext -import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrConstructor import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.types.isNullableString -import org.jetbrains.kotlin.ir.types.isString import org.jetbrains.kotlin.ir.types.makeNotNull -import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.isThrowable -import org.jetbrains.kotlin.ir.util.isThrowableTypeOrSubtype import org.jetbrains.kotlin.ir.visitors.IrElementTransformer @@ -74,7 +67,7 @@ class ThrowableLowering(val context: JsIrBackendContext) : FileLoweringPass { val (messageArg, causeArg) = expression.extractThrowableArguments() return expression.run { - IrCallImpl(startOffset, endOffset, type, newThrowableFunction, newThrowableFunction.descriptor).also { + IrCallImpl(startOffset, endOffset, type, newThrowableFunction).also { it.putValueArgument(0, messageArg) it.putValueArgument(1, causeArg) } @@ -91,7 +84,7 @@ class ThrowableLowering(val context: JsIrBackendContext) : FileLoweringPass { val thisReceiver = IrGetValueImpl(expression.startOffset, expression.endOffset, klass.thisReceiver!!.symbol) return expression.run { - IrCallImpl(startOffset, endOffset, type, extendThrowableFunction, extendThrowableFunction.descriptor).also { + IrCallImpl(startOffset, endOffset, type, extendThrowableFunction).also { it.putValueArgument(0, thisReceiver) it.putValueArgument(1, messageArg) it.putValueArgument(2, causeArg) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt index a07165626f4..45f8d643aba 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/BridgeLowering.kt @@ -284,8 +284,7 @@ private class BridgeLowering(val context: JvmBackendContext) : ClassLoweringPass IrCallImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, maybeOrphanedTarget.returnType, - maybeOrphanedTarget.symbol, maybeOrphanedTarget.descriptor, - origin = IrStatementOrigin.BRIDGE_DELEGATION, + maybeOrphanedTarget.symbol, origin = IrStatementOrigin.BRIDGE_DELEGATION, superQualifierSymbol = if (invokeStatically) maybeOrphanedTarget.parentAsClass.symbol else null ).apply { passTypeArgumentsFrom(this@createBridgeBody) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt index 0eda9d59486..00c3a00b47f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/EnumClassLowering.kt @@ -271,7 +271,6 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP endOffset, context.irBuiltIns.unitType, enumConstructorCall.symbol, - enumConstructorCall.descriptor, enumConstructorCall.typeArgumentsCount ) @@ -309,7 +308,6 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP endOffset, context.irBuiltIns.unitType, loweredDelegatedConstructor.symbol, - loweredDelegatedConstructor.descriptor, loweredDelegatedConstructor.typeParameters.size ) @@ -370,7 +368,6 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP endOffset, context.irBuiltIns.unitType, loweredConstructor.symbol, - loweredConstructor.descriptor, loweredConstructor.typeParameters.size ) } @@ -489,7 +486,6 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP UNDEFINED_OFFSET, returnType, enumValueOf, - substitutedValueOfDescriptor, enumValueOf.owner.typeParameters.size ) irValueOfCall.putTypeArgument(0, irClass.defaultType) @@ -515,7 +511,7 @@ private class EnumClassLowering(val context: JvmBackendContext) : ClassLoweringP val cloneFun = context.irBuiltIns.arrayClass.owner.functions.find { it.name.asString() == "clone" }!! val returnType = valuesFunction.symbol.owner.returnType val irCloneValues = - IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, returnType, cloneFun.symbol, cloneFun.descriptor, 0).apply { + IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, returnType, cloneFun.symbol, 0).apply { dispatchReceiver = IrGetFieldImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, valuesField.symbol, valuesField.symbol.owner.type) } 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 25129f8e04d..b36b1f87c5a 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 @@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.jvm.lower import org.jetbrains.kotlin.backend.common.FileLoweringPass import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext -import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom import org.jetbrains.kotlin.backend.common.lower.createIrBuilder import org.jetbrains.kotlin.backend.common.lower.irBlock import org.jetbrains.kotlin.backend.common.phaser.makeIrFilePhase @@ -106,7 +105,6 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte expression.endOffset, field.type, function.symbol, - function.symbol.descriptor, typeArgumentsCount = 0, origin = IrStatementOrigin.LAMBDA ).apply { @@ -145,7 +143,7 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte expression.endOffset ).run { irExprBody(irCall(referencedFunction).apply { - this@apply.descriptor.typeParameters.forEach { + this@apply.symbol.owner.allTypeParameters.forEach { putTypeArgument(it.index, expression.getTypeArgument(it.index)) } @@ -176,7 +174,6 @@ internal class InlineCallableReferenceToLambdaPhase(val context: JvmBackendConte expression.endOffset, referencedFunction.returnType, function.symbol, - function.symbol.descriptor, referencedFunction.typeParameters.size, IrStatementOrigin.LAMBDA ).apply { 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 bc5bef6200e..ca89155898b 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 @@ -218,7 +218,6 @@ internal class InterfaceLowering(val context: JvmBackendContext) : IrElementTran endOffset, type, newFunction.symbol, - newFunction.descriptor, typeArgumentsCount, origin ).apply { 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 e0007b2e231..4066ea47441 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 @@ -225,9 +225,8 @@ private class JvmInlineClassLowering(private val context: JvmBackendContext) : F return IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type, - function.symbol, function.descriptor, - function.typeParameters.size, function.valueParameters.size, - expression.origin + function.symbol, function.typeParameters.size, + function.valueParameters.size, 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/JvmOverloadsAnnotationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/JvmOverloadsAnnotationLowering.kt index 97424268101..7c34a66c9a5 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 @@ -58,7 +58,7 @@ private class JvmOverloadsAnnotationLowering(val context: JvmBackendContext) : C val wrapperIrFunction = generateWrapperHeader(target, numDefaultParametersToExpect) val call = if (target is IrConstructor) - IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol, target.descriptor) + IrDelegatingConstructorCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, target.symbol) else IrCallImpl(UNDEFINED_OFFSET, UNDEFINED_OFFSET, target.returnType, target.symbol) for (arg in wrapperIrFunction.allTypeParameters) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MainMethodGenerationLowering.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MainMethodGenerationLowering.kt index 327802083aa..60f99c0105a 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MainMethodGenerationLowering.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/MainMethodGenerationLowering.kt @@ -23,12 +23,9 @@ import org.jetbrains.kotlin.ir.builders.irReturn import org.jetbrains.kotlin.ir.declarations.IrClass import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction -import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl import org.jetbrains.kotlin.ir.types.* import org.jetbrains.kotlin.ir.util.functions -import org.jetbrains.kotlin.ir.util.getAnnotation import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.types.Variance internal class MainMethodGenerationLowering(val context: JvmBackendContext) : ClassLoweringPass { 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 af78f84a71a..e1526b0313a 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 @@ -111,7 +111,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle expression.transformChildrenVoid() return IrFunctionReferenceImpl( expression.startOffset, expression.endOffset, expression.type, - accessor, accessor.descriptor, accessor.owner.typeParameters.size, + accessor, accessor.owner.typeParameters.size, accessor.owner.valueParameters.size, expression.origin ) } @@ -183,8 +183,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle IrDelegatingConstructorCallImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, context.irBuiltIns.unitType, - targetSymbol, targetSymbol.descriptor, - targetSymbol.owner.parentAsClass.typeParameters.size + targetSymbol.owner.typeParameters.size + targetSymbol, targetSymbol.owner.parentAsClass.typeParameters.size + targetSymbol.owner.typeParameters.size ).also { copyAllParamsToArgs(it, accessor) } @@ -250,8 +249,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle IrCallImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, accessor.returnType, - targetSymbol, targetSymbol.descriptor, - targetSymbol.owner.typeParameters.size, + targetSymbol, targetSymbol.owner.typeParameters.size, superQualifierSymbol = superQualifierSymbol ).also { copyAllParamsToArgs(it, accessor) @@ -344,15 +342,13 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle is IrCall -> IrCallImpl( oldExpression.startOffset, oldExpression.endOffset, oldExpression.type, - accessorSymbol, accessorSymbol.descriptor, - oldExpression.typeArgumentsCount, + accessorSymbol, oldExpression.typeArgumentsCount, oldExpression.origin ) is IrDelegatingConstructorCall -> IrDelegatingConstructorCallImpl( oldExpression.startOffset, oldExpression.endOffset, context.irBuiltIns.unitType, - accessorSymbol as IrConstructorSymbol, accessorSymbol.descriptor, - oldExpression.typeArgumentsCount + accessorSymbol as IrConstructorSymbol, oldExpression.typeArgumentsCount ) is IrConstructorCall -> IrConstructorCallImpl.fromSymbolDescriptor( @@ -388,8 +384,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle val call = IrCallImpl( oldExpression.startOffset, oldExpression.endOffset, oldExpression.type, - accessorSymbol, accessorSymbol.descriptor, - 0, + accessorSymbol, 0, oldExpression.origin ) oldExpression.receiver?.let { @@ -405,8 +400,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle val call = IrCallImpl( oldExpression.startOffset, oldExpression.endOffset, oldExpression.type, - accessorSymbol, accessorSymbol.descriptor, - 0, + accessorSymbol, 0, oldExpression.origin ) oldExpression.receiver?.let { diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt index d28429a73ae..61b5efb936b 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/BodyGenerator.kt @@ -261,8 +261,7 @@ class BodyGenerator( IrDelegatingConstructorCallImpl( ktElement.pureStartOffset, ktElement.pureEndOffset, context.irBuiltIns.unitType, - context.symbolTable.referenceConstructor(anyConstructor), - anyConstructor + context.symbolTable.referenceConstructor(anyConstructor) ) ) } 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 360e3e4e765..e99130a25c6 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 @@ -125,8 +125,7 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator val getterDescriptor = descriptor.getter!! val getterSymbol = context.symbolTable.referenceFunction(getterDescriptor.original) IrCallImpl( - startOffset, endOffset, descriptor.type.toIrType(), getterSymbol, getterDescriptor, - origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY + startOffset, endOffset, descriptor.type.toIrType(), getterSymbol, origin ?: IrStatementOrigin.GET_LOCAL_PROPERTY ).apply { putTypeArguments(typeArguments) { it.toIrType() } } @@ -141,8 +140,7 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator val irCall = IrDelegatingConstructorCallImpl( startOffset, endOffset, context.irBuiltIns.unitType, - constructorSymbol, - descriptor + constructorSymbol ).apply { putTypeArguments(call.typeArguments) { it.toIrType() } this.dispatchReceiver = dispatchReceiver?.load() @@ -205,7 +203,6 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator startOffset, endOffset, irType, getterSymbol, - getMethodDescriptor, descriptor.typeParametersCount, 0, IrStatementOrigin.GET_PROPERTY, @@ -249,11 +246,12 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator ): IrExpression = call.callReceiver.call { dispatchReceiverValue, extensionReceiverValue -> val irType = constructorDescriptor.returnType.toIrType() + val originalSymbol = context.symbolTable.referenceConstructor(constructorDescriptor.original) + IrConstructorCallImpl.fromSubstitutedDescriptor( startOffset, endOffset, irType, - context.symbolTable.referenceConstructor(constructorDescriptor.original), - constructorDescriptor, + originalSymbol, origin ).run { putTypeArguments(call.typeArguments) { it.toIrType() } @@ -322,11 +320,11 @@ class CallGenerator(statementGenerator: StatementGenerator) : StatementGenerator ) } } else { + val originalSymbol = context.symbolTable.referenceFunction(functionDescriptor.original) IrCallImpl( startOffset, endOffset, irType, - context.symbolTable.referenceFunction(functionDescriptor.original), - functionDescriptor, + originalSymbol, origin, call.superQualifier?.let { context.symbolTable.referenceClass(it) } ).run { 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 de242280a8d..a7e4352e69c 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 @@ -279,10 +279,10 @@ class ClassGenerator( val substitutedOverridden = substituteOverriddenDescriptorForDelegate(delegated, overridden) val returnType = substitutedOverridden.returnType!! val irReturnType = returnType.toIrType() + val originalSymbol = context.symbolTable.referenceFunction(overridden.original) val irCall = IrCallImpl( startOffset, endOffset, irReturnType, - context.symbolTable.referenceFunction(overridden.original), - substitutedOverridden, + originalSymbol, substitutedOverridden.typeParametersCount ).apply { val typeArguments = getTypeArgumentsForOverriddenDescriptorDelegatingCall(delegated, overridden) diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt index f6834786f3e..7a034042935 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/DataClassMembersGenerator.kt @@ -258,7 +258,7 @@ class DataClassMembersGenerator( val hashCodeFunctionDescriptor = getHashCodeFunction(kotlinType) val hashCodeFunctionSymbol = declarationGenerator.context.symbolTable.referenceFunction(hashCodeFunctionDescriptor.original) return irCall(hashCodeFunctionSymbol, context.irBuiltIns.intType).apply { - if (descriptor.dispatchReceiverParameter != null) { + if (hashCodeFunctionDescriptor.dispatchReceiverParameter != null) { dispatchReceiver = irValue } else { putValueArgument(0, irValue) 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 6901294c7a1..e03fcac3a3e 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 @@ -412,18 +412,19 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat endOffset: Int, functionDescriptor: FunctionDescriptor, receiver: IrExpression - ): IrExpression = - IrCallImpl( + ): IrExpression { + val originalSymbol = context.symbolTable.referenceFunction(functionDescriptor.original) + return IrCallImpl( startOffset, endOffset, functionDescriptor.returnType!!.toIrType(), - context.symbolTable.referenceFunction(functionDescriptor.original), - functionDescriptor, - origin = null, // TODO origin for widening conversions? + originalSymbol, + origin = null, superQualifierSymbol = null ).apply { dispatchReceiver = receiver } + } private fun KotlinType.findConversionFunctionTo(targetType: KotlinType): FunctionDescriptor? { val targetTypeName = targetType.constructor.declarationDescriptor?.name?.asString() ?: return null @@ -498,11 +499,11 @@ class OperatorExpressionGenerator(statementGenerator: StatementGenerator) : Stat ) ) ?: throw AssertionError("Substitution failed for $checkNotNull: T=$argumentType") + val checkNotNullSymbol = context.irBuiltIns.checkNotNullSymbol return IrCallImpl( ktOperator.startOffsetSkippingComments, ktOperator.endOffset, expressionType.toIrType(), - context.irBuiltIns.checkNotNullSymbol, - checkNotNullSubstituted, + checkNotNullSymbol, origin ).apply { 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 b12a0397604..98212fd7d52 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 @@ -137,11 +137,11 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St val originalProperty = propertyDescriptor.original val originalGetter = originalProperty.getter?.original val originalSetter = if (mutable) originalProperty.setter?.original else null + val originalSymbol = context.symbolTable.referenceProperty(originalProperty) return IrPropertyReferenceImpl( startOffset, endOffset, type.toIrType(), - context.symbolTable.referenceProperty(originalProperty), - propertyDescriptor, + originalSymbol, propertyDescriptor.typeParametersCount, getFieldForPropertyReference(originalProperty), originalGetter?.let { context.symbolTable.referenceSimpleFunction(it) }, @@ -172,8 +172,7 @@ class ReflectionReferencesGenerator(statementGenerator: StatementGenerator) : St ): IrFunctionReference = IrFunctionReferenceImpl( startOffset, endOffset, type.toIrType(), - symbol, descriptor, descriptor.typeParametersCount, - origin + symbol, descriptor.typeParametersCount, origin ).apply { putTypeArguments(typeArguments) { it.toIrType() } } 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 82aa7678fbd..4c7ecbb3b20 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 @@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.types.KotlinType class DelegatedLocalPropertyLValue( private val context: IrGeneratorContext, @@ -37,10 +36,10 @@ class DelegatedLocalPropertyLValue( AssignmentReceiver { override fun load(): IrExpression = - IrCallImpl(startOffset, endOffset, type, getterSymbol!!, getterSymbol.descriptor, origin) + IrCallImpl(startOffset, endOffset, type, getterSymbol!!, origin) override fun store(irExpression: IrExpression): IrExpression = - IrCallImpl(startOffset, endOffset, context.irBuiltIns.unitType, setterSymbol!!, setterSymbol.descriptor, origin).apply { + IrCallImpl(startOffset, endOffset, context.irBuiltIns.unitType, setterSymbol!!, origin).apply { putValueArgument(0, irExpression) } diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/PropertyLValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/PropertyLValue.kt index fe284381b58..12e83087aaa 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/PropertyLValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/PropertyLValue.kt @@ -145,8 +145,7 @@ class AccessorPropertyLValue( IrCallImpl( startOffset, endOffset, type, - getter!!, getterDescriptor, - typeArgumentsCount, + getter!!, typeArgumentsCount, 0, origin, superQualifier @@ -162,8 +161,7 @@ class AccessorPropertyLValue( IrCallImpl( startOffset, endOffset, context.irBuiltIns.unitType, - setter!!, setterDescriptor, - typeArgumentsCount, + setter!!, typeArgumentsCount, 1, origin, superQualifier diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt index 597c6fa93de..64af781c7dd 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/ExpressionHelpers.kt @@ -196,7 +196,6 @@ fun IrBuilderWithScope.irGet(type: IrType, receiver: IrExpression?, getterSymbol startOffset, endOffset, type, getterSymbol as IrSimpleFunctionSymbol, - getterSymbol.descriptor, typeArgumentsCount = getterSymbol.owner.typeParameters.size, valueArgumentsCount = 0, origin = IrStatementOrigin.GET_PROPERTY @@ -209,7 +208,6 @@ fun IrBuilderWithScope.irSet(type: IrType, receiver: IrExpression?, setterSymbol startOffset, endOffset, type, setterSymbol as IrSimpleFunctionSymbol, - setterSymbol.descriptor, typeArgumentsCount = setterSymbol.owner.typeParameters.size, valueArgumentsCount = 1, origin = IrStatementOrigin.EQ @@ -242,7 +240,7 @@ fun IrBuilderWithScope.irCallConstructor(callee: IrConstructorSymbol, typeArgume } fun IrBuilderWithScope.irCall(callee: IrSimpleFunctionSymbol, type: IrType): IrCall = - IrCallImpl(startOffset, endOffset, type, callee, callee.descriptor) + IrCallImpl(startOffset, endOffset, type, callee) fun IrBuilderWithScope.irCall(callee: IrConstructorSymbol, type: IrType): IrConstructorCall = IrConstructorCallImpl.fromSymbolDescriptor(startOffset, endOffset, type, callee) @@ -264,7 +262,7 @@ fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol): IrFunctionAccessExpress irCall(callee, callee.owner.returnType) fun IrBuilderWithScope.irCall(callee: IrFunctionSymbol, descriptor: FunctionDescriptor, type: IrType): IrCall = - IrCallImpl(startOffset, endOffset, type, callee as IrSimpleFunctionSymbol, descriptor) + IrCallImpl(startOffset, endOffset, type, callee as IrSimpleFunctionSymbol) fun IrBuilderWithScope.irCall(callee: IrFunction): IrFunctionAccessExpression = irCall(callee.symbol) @@ -273,12 +271,13 @@ fun IrBuilderWithScope.irCall(callee: IrFunction, origin: IrStatementOrigin): Ir IrCallImpl( startOffset, endOffset, callee.returnType, callee.symbol as IrSimpleFunctionSymbol, - callee.descriptor, origin + callee.typeParameters.size, callee.valueParameters.size, + origin ) fun IrBuilderWithScope.irDelegatingConstructorCall(callee: IrConstructor): IrDelegatingConstructorCall = IrDelegatingConstructorCallImpl( - startOffset, endOffset, context.irBuiltIns.unitType, callee.symbol, callee.descriptor, + startOffset, endOffset, context.irBuiltIns.unitType, callee.symbol, callee.parentAsClass.typeParameters.size, callee.valueParameters.size ) @@ -379,14 +378,3 @@ inline fun IrBuilderWithScope.irBlockBody( endOffset ).blockBody(body) -fun IrBuilderWithScope.irThrowIse(origin: IrStatementOrigin? = null) = - IrCallImpl( - startOffset, endOffset, - context.irBuiltIns.nothingType, - context.irBuiltIns.throwIseSymbol, - context.irBuiltIns.throwIseSymbol.descriptor, - typeArgumentsCount = 0, - valueArgumentsCount = 0, - origin = origin - ) - diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt index a6f9619f471..29aa4cb2053 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/builders/Primitives.kt @@ -33,7 +33,7 @@ fun primitiveOp1( origin: IrStatementOrigin, dispatchReceiver: IrExpression ): IrExpression = - IrCallImpl(startOffset, endOffset, primitiveOpReturnType, primitiveOpSymbol, primitiveOpSymbol.descriptor, origin = origin).also { + IrCallImpl(startOffset, endOffset, primitiveOpReturnType, primitiveOpSymbol, origin = origin).also { it.dispatchReceiver = dispatchReceiver } @@ -47,8 +47,7 @@ fun primitiveOp2( IrCallImpl( startOffset, endOffset, primitiveOpReturnType, - primitiveOpSymbol, primitiveOpSymbol.descriptor, - typeArgumentsCount = 0, + primitiveOpSymbol, typeArgumentsCount = 0, valueArgumentsCount = 2, origin = origin ).apply { 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 79a49b5b8e7..553b715bbbb 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 @@ -16,13 +16,12 @@ package org.jetbrains.kotlin.ir.expressions.impl -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.ConstructorDescriptor import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.ir.expressions.IrCall import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin import org.jetbrains.kotlin.ir.expressions.typeParametersCount import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.visitors.IrElementVisitor @@ -32,7 +31,6 @@ class IrCallImpl( endOffset: Int, type: IrType, override val symbol: IrFunctionSymbol, - override val descriptor: FunctionDescriptor, typeArgumentsCount: Int, valueArgumentsCount: Int, origin: IrStatementOrigin? = null, @@ -47,22 +45,23 @@ class IrCallImpl( IrCall { init { - if (descriptor is ConstructorDescriptor) { - throw AssertionError("Should be IrConstructorCall: $descriptor") + if (symbol is IrConstructorSymbol) { + throw AssertionError("Should be IrConstructorCall: ${symbol.descriptor}") } } + override val descriptor: FunctionDescriptor get() = symbol.descriptor + constructor( startOffset: Int, endOffset: Int, type: IrType, symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null ) : this( - startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount, - descriptor.valueParameters.size, origin, superQualifierSymbol + startOffset, endOffset, type, symbol, symbol.descriptor.typeParametersCount, symbol.descriptor.valueParameters.size, + origin, superQualifierSymbol ) constructor( @@ -70,13 +69,12 @@ class IrCallImpl( endOffset: Int, type: IrType, symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null, superQualifierSymbol: IrClassSymbol? = null ) : this( - startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, - descriptor.valueParameters.size, origin, superQualifierSymbol + startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size, + origin, superQualifierSymbol ) override fun accept(visitor: IrElementVisitor, data: D): R = diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt index 8145db61e17..175756094be 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrConstructorCallImpl.kt @@ -19,7 +19,6 @@ class IrConstructorCallImpl( endOffset: Int, type: IrType, override val symbol: IrConstructorSymbol, - override val descriptor: ClassConstructorDescriptor, typeArgumentsCount: Int, override val constructorTypeArgumentsCount: Int, valueArgumentsCount: Int, @@ -31,6 +30,8 @@ class IrConstructorCallImpl( override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitConstructorCall(this, data) + override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor + companion object { fun fromSubstitutedDescriptor( startOffset: Int, @@ -48,7 +49,6 @@ class IrConstructorCallImpl( startOffset, endOffset, type, constructorSymbol, - constructorDescriptor, totalTypeParametersCount, totalTypeParametersCount - classTypeParametersCount, valueParametersCount, @@ -83,7 +83,6 @@ class IrConstructorCallImpl( startOffset, endOffset, type, constructorSymbol, - constructorSymbol.descriptor, totalTypeParametersCount, constructorTypeParametersCount, valueParametersCount, diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt index 001548b87d7..26076450e88 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrDelegatingConstructorCallImpl.kt @@ -28,7 +28,6 @@ class IrDelegatingConstructorCallImpl( endOffset: Int, type: IrType, override val symbol: IrConstructorSymbol, - override val descriptor: ClassConstructorDescriptor, typeArgumentsCount: Int, valueArgumentsCount: Int ) : @@ -41,29 +40,22 @@ class IrDelegatingConstructorCallImpl( ), IrDelegatingConstructorCall { - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrConstructorSymbol, - descriptor: ClassConstructorDescriptor - ) : this(startOffset, endOffset, type, symbol, descriptor, descriptor.typeParametersCount, descriptor.valueParameters.size) - constructor( startOffset: Int, endOffset: Int, type: IrType, symbol: IrConstructorSymbol - ) : this(startOffset, endOffset, type, symbol, symbol.descriptor) + ) : this(startOffset, endOffset, type, symbol, symbol.descriptor.typeParametersCount, symbol.descriptor.valueParameters.size) constructor( startOffset: Int, endOffset: Int, type: IrType, symbol: IrConstructorSymbol, - descriptor: ClassConstructorDescriptor, typeArgumentsCount: Int - ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size) + ) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size) + + override val descriptor: ClassConstructorDescriptor get() = symbol.descriptor override fun accept(visitor: IrElementVisitor, data: D): R { return visitor.visitDelegatingConstructorCall(this, data) 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 9af008f9ffe..ceba7844a46 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 @@ -28,7 +28,6 @@ class IrFunctionReferenceImpl( endOffset: Int, type: IrType, override val symbol: IrFunctionSymbol, - override val descriptor: FunctionDescriptor, typeArgumentsCount: Int, valueArgumentsCount: Int, origin: IrStatementOrigin? = null @@ -48,10 +47,11 @@ class IrFunctionReferenceImpl( endOffset: Int, type: IrType, symbol: IrFunctionSymbol, - descriptor: FunctionDescriptor, typeArgumentsCount: Int, origin: IrStatementOrigin? = null - ) : this(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, descriptor.valueParameters.size, origin) + ) : this(startOffset, endOffset, type, symbol, typeArgumentsCount, symbol.descriptor.valueParameters.size, origin) + + override val descriptor: FunctionDescriptor get() = symbol.descriptor override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitFunctionReference(this, data) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt index 17cb397c7f4..5fa3c894724 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyReferenceImpl.kt @@ -31,7 +31,6 @@ class IrPropertyReferenceImpl( endOffset: Int, type: IrType, override val symbol: IrPropertySymbol, - override val descriptor: PropertyDescriptor, typeArgumentsCount: Int, override val field: IrFieldSymbol?, override val getter: IrSimpleFunctionSymbol?, @@ -41,22 +40,6 @@ class IrPropertyReferenceImpl( IrNoArgumentsCallableReferenceBase(startOffset, endOffset, type, typeArgumentsCount, origin), IrPropertyReference { - constructor( - startOffset: Int, - endOffset: Int, - type: IrType, - symbol: IrPropertySymbol, - typeArgumentsCount: Int, - field: IrFieldSymbol?, - getter: IrSimpleFunctionSymbol?, - setter: IrSimpleFunctionSymbol?, - origin: IrStatementOrigin? = null - ) : this( - startOffset, endOffset, type, - symbol, symbol.descriptor, - typeArgumentsCount, field, getter, setter, origin - ) - @Deprecated(message = "Don't use descriptor-based API for IrPropertyReference", level = DeprecationLevel.WARNING) constructor( startOffset: Int, @@ -74,6 +57,8 @@ class IrPropertyReferenceImpl( typeArgumentsCount, field, getter, setter, origin ) + override val descriptor: PropertyDescriptor get() = symbol.descriptor + override fun accept(visitor: IrElementVisitor, data: D): R = visitor.visitPropertyReference(this, data) } \ No newline at end of file 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 4fad13596f8..a2de99691a2 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 @@ -495,7 +495,6 @@ open class DeepCopyIrTreeWithSymbols( expression.startOffset, expression.endOffset, expression.type.remapType(), constructorSymbol, - constructorSymbol.descriptor, expression.typeArgumentsCount, expression.constructorTypeArgumentsCount, expression.valueArgumentsCount, @@ -521,7 +520,6 @@ open class DeepCopyIrTreeWithSymbols( expression.startOffset, expression.endOffset, expression.type.remapType(), newCallee, - newCallee.descriptor, expression.typeArgumentsCount, expression.valueArgumentsCount, mapStatementOrigin(expression.origin), @@ -550,7 +548,6 @@ open class DeepCopyIrTreeWithSymbols( expression.startOffset, expression.endOffset, expression.type.remapType(), newConstructor, - newConstructor.descriptor, expression.typeArgumentsCount ).apply { copyRemappedTypeArgumentsFrom(expression) @@ -584,7 +581,6 @@ open class DeepCopyIrTreeWithSymbols( expression.startOffset, expression.endOffset, expression.type.remapType(), symbol, - symbol.descriptor, expression.typeArgumentsCount, expression.valueArgumentsCount, mapStatementOrigin(expression.origin) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt index e7ab6c29005..1417296c3ad 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/util/IrUtils.kt @@ -482,7 +482,6 @@ fun irConstructorCall( endOffset, type, newSymbol, - newSymbol.descriptor, typeArgumentsCount, 0, call.valueArgumentsCount, @@ -521,7 +520,6 @@ fun irCall( endOffset, type, newSymbol, - newSymbol.descriptor, typeArgumentsCount, origin ).apply { 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 3c11dc155d2..a0d9cb729b9 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 @@ -350,8 +350,7 @@ abstract class IrFileDeserializer( val symbol = deserializeIrSymbol(proto.symbol) as IrConstructorSymbol return IrConstructorCallImpl( start, end, type, - symbol, symbol.descriptor, - typeArgumentsCount = proto.memberAccess.typeArguments.typeArgumentCount, + symbol, typeArgumentsCount = proto.memberAccess.typeArguments.typeArgumentCount, constructorTypeArgumentsCount = proto.constructorTypeArgumentsCount, valueArgumentsCount = proto.memberAccess.valueArgumentCount ).also { @@ -372,8 +371,7 @@ abstract class IrFileDeserializer( // TODO: implement the last three args here. IrCallImpl( start, end, type, - symbol, symbol.descriptor, - proto.memberAccess.typeArguments.typeArgumentCount, + symbol, proto.memberAccess.typeArguments.typeArgumentCount, proto.memberAccess.valueArgumentList.size, origin, superSymbol @@ -404,7 +402,6 @@ abstract class IrFileDeserializer( end, builtIns.unitType, symbol, - symbol.descriptor, proto.memberAccess.typeArguments.typeArgumentCount, proto.memberAccess.valueArgumentList.size ) @@ -457,7 +454,6 @@ abstract class IrFileDeserializer( end, type, symbol, - symbol.descriptor, proto.memberAccess.typeArguments.typeArgumentCount, proto.memberAccess.valueArgumentCount, origin diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt index 1c05d013245..f9336aad660 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/GeneratorHelpers.kt @@ -226,8 +226,7 @@ interface IrBuilderExtension { +IrDelegatingConstructorCallImpl( startOffset, endOffset, compilerContext.irBuiltIns.unitType, - compilerContext.externalSymbols.referenceConstructor(anyConstructor), - anyConstructor + compilerContext.externalSymbols.referenceConstructor(anyConstructor) ) } } diff --git a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt index 2fbbfd80334..37066c3f5ca 100644 --- a/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt +++ b/plugins/kotlin-serialization/kotlin-serialization-compiler/src/org/jetbrains/kotlinx/serialization/compiler/backend/ir/SerializableIrGenerator.kt @@ -119,8 +119,7 @@ class SerializableIrGenerator( startOffset, endOffset, compilerContext.irBuiltIns.unitType, - ctorRef, - suitableCtor + ctorRef ) call.insertTypeArgumentsForSuperClass(superClass) +call @@ -152,8 +151,7 @@ class SerializableIrGenerator( startOffset, endOffset, compilerContext.irBuiltIns.unitType, - superCtorRef, - superCtorRef.owner.descriptor + superCtorRef ) arguments.forEachIndexed { index, parameter -> call.putValueArgument(index, irGet(parameter)) } call.insertTypeArgumentsForSuperClass(superClass)