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 797707474cf..19ba10e4c01 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 @@ -23,7 +23,6 @@ import org.jetbrains.kotlin.backend.common.descriptors.* import org.jetbrains.kotlin.backend.common.lower.VariableRemapper import org.jetbrains.kotlin.descriptors.ClassKind import org.jetbrains.kotlin.descriptors.Modality -import org.jetbrains.kotlin.descriptors.ReceiverParameterDescriptor import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.ir.IrElement @@ -152,10 +151,9 @@ fun IrValueParameter.copyTo( varargElementType: IrType? = this.varargElementType, defaultValue: IrExpressionBody? = this.defaultValue, isCrossinline: Boolean = this.isCrossinline, - isNoinline: Boolean = this.isNoinline, - receiverToValue: Boolean = false + isNoinline: Boolean = this.isNoinline ): IrValueParameter { - val descriptor = if (this.descriptor is ReceiverParameterDescriptor && !receiverToValue) { + val descriptor = if (index < 0) { WrappedReceiverParameterDescriptor(this.descriptor.annotations, this.descriptor.source) } else { WrappedValueParameterDescriptor(this.descriptor.annotations, this.descriptor.source) @@ -262,8 +260,7 @@ fun IrFunction.copyValueParametersToStatic( origin = originalDispatchReceiver.origin, index = shift++, type = type, - name = Name.identifier("\$this"), - receiverToValue = true + name = Name.identifier("\$this") ) ) } @@ -273,8 +270,7 @@ fun IrFunction.copyValueParametersToStatic( target, origin = originalExtensionReceiver.origin, index = shift++, - name = Name.identifier("\$receiver"), - receiverToValue = true + name = Name.identifier("\$receiver") ) ) } @@ -541,14 +537,12 @@ fun createStaticFunctionWithReceivers( this, name = Name.identifier("this"), index = offset++, - type = dispatchReceiverType!!, - receiverToValue = true + type = dispatchReceiverType!! ) val extensionReceiver = oldFunction.extensionReceiverParameter?.copyTo( this, name = Name.identifier("receiver"), - index = offset++, - receiverToValue = true + index = offset++ ) valueParameters.addAll(listOfNotNull(dispatchReceiver, extensionReceiver) + oldFunction.valueParameters.map { it.copyTo(this, index = it.index + offset) } diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt index f0b93f0992a..fd417f73394 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AbstractSuspendFunctionsLowering.kt @@ -400,7 +400,7 @@ abstract class AbstractSuspendFunctionsLowering(val co coroutineConstructors += this functionParameters.mapIndexedTo(valueParameters) { index, parameter -> - parameter.copyTo(this, DECLARATION_ORIGIN_COROUTINE_IMPL, index, receiverToValue = true) + parameter.copyTo(this, DECLARATION_ORIGIN_COROUTINE_IMPL, index) } val continuationParameter = coroutineBaseClassConstructor.valueParameters[0] valueParameters += continuationParameter.copyTo( @@ -445,7 +445,7 @@ abstract class AbstractSuspendFunctionsLowering(val co coroutineConstructors += this boundParams.mapIndexedTo(valueParameters) { index, parameter -> - parameter.copyTo(this, DECLARATION_ORIGIN_COROUTINE_IMPL, index, receiverToValue = true) + parameter.copyTo(this, DECLARATION_ORIGIN_COROUTINE_IMPL, index) } val irBuilder = context.createIrBuilder(symbol, startOffset, endOffset) @@ -497,7 +497,7 @@ abstract class AbstractSuspendFunctionsLowering(val co (unboundArgs + create1CompletionParameter) .mapIndexedTo(valueParameters) { index, parameter -> - parameter.copyTo(this, DECLARATION_ORIGIN_COROUTINE_IMPL, index, receiverToValue = true) + parameter.copyTo(this, DECLARATION_ORIGIN_COROUTINE_IMPL, index) } this.createDispatchReceiverParameter() 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 637b5769e37..47934fa5ed6 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 @@ -240,8 +240,7 @@ internal class CallableReferenceLowering(val context: JvmBackendContext) : FileL valueParameters += param.copyTo( this, index = valueParameters.size, - type = param.type.substitute(typeArgumentsMap), - receiverToValue = true + type = param.type.substitute(typeArgumentsMap) ) } diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt index e1cec83d633..03b5aabdd21 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/lower/inlineclasses/MemoizedInlineClassReplacements.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.ir.copyTypeParameters import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom import org.jetbrains.kotlin.backend.common.ir.createDispatchReceiverParameter import org.jetbrains.kotlin.backend.jvm.JvmLoweredDeclarationOrigin -import org.jetbrains.kotlin.backend.jvm.ir.erasedUpperBound import org.jetbrains.kotlin.backend.jvm.lower.inlineclasses.InlineClassAbi.mangledNameFor import org.jetbrains.kotlin.ir.builders.declarations.addValueParameter import org.jetbrains.kotlin.ir.builders.declarations.buildFun @@ -19,14 +18,11 @@ import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.declarations.impl.IrFunctionImpl import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol -import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.getClass import org.jetbrains.kotlin.ir.util.constructedClass import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.explicitParameters -import org.jetbrains.kotlin.ir.util.fqNameWhenAvailable import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.storage.LockBasedStorageManager class IrReplacementFunction( @@ -128,7 +124,7 @@ class MemoizedInlineClassReplacements { newParameter = parameter.copyTo(this, index = -1, name = name) dispatchReceiverParameter = newParameter } else { - newParameter = parameter.copyTo(this, index = index - 1, name = name, receiverToValue = true) + newParameter = parameter.copyTo(this, index = index - 1, name = name) valueParameters.add(newParameter) } parameterMap[parameter.symbol] = newParameter @@ -150,7 +146,7 @@ class MemoizedInlineClassReplacements { else -> parameter.name } - val newParameter = parameter.copyTo(this, index = index, name = name, receiverToValue = true) + val newParameter = parameter.copyTo(this, index = index, name = name) valueParameters.add(newParameter) parameterMap[parameter.symbol] = newParameter }