diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt index df1ac4efaab..4f53fad863f 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt @@ -76,7 +76,7 @@ internal val Context.getBoxFunction: (IrClass) -> IrSimpleFunction by Context.la isFakeOverride = false, isOperator = false ).also { function -> - function.valueParameters.add(WrappedValueParameterDescriptor().let { + function.valueParameters = listOf(WrappedValueParameterDescriptor().let { IrValueParameterImpl( startOffset, endOffset, IrDeclarationOrigin.DEFINED, @@ -130,7 +130,7 @@ internal val Context.getUnboxFunction: (IrClass) -> IrSimpleFunction by Context. isFakeOverride = false, isOperator = false ).also { function -> - function.valueParameters.add(WrappedValueParameterDescriptor().let { + function.valueParameters = listOf(WrappedValueParameterDescriptor().let { IrValueParameterImpl( startOffset, endOffset, IrDeclarationOrigin.DEFINED, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt index 2841a4c1b1d..69294fba725 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt @@ -126,7 +126,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory( builtClassesMap.getOrPut(descriptor) { createClass(descriptor).apply { val functionClass = this - descriptor.declaredTypeParameters.mapTo(typeParameters) { typeParameterDescriptor -> + typeParameters += descriptor.declaredTypeParameters.map { typeParameterDescriptor -> createTypeParameter(typeParameterDescriptor).also { it.parent = this it.superTypes += irBuiltIns.anyNType @@ -134,7 +134,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory( } val descriptorToIrParametersMap = typeParameters.map { it.descriptor to it }.toMap() - descriptor.typeConstructor.supertypes.mapTo(superTypes) { superType -> + superTypes += descriptor.typeConstructor.supertypes.map { superType -> val arguments = superType.arguments.map { argument -> val argumentClassifierDescriptor = argument.type.constructor.declarationDescriptor val argumentClassifierSymbol = argumentClassifierDescriptor?.let { descriptorToIrParametersMap[it] } @@ -165,7 +165,7 @@ internal class BuiltInFictitiousFunctionIrClassFactory( typeParameters.last().defaultType ).apply { parent = functionClass - invokeFunctionDescriptor.valueParameters.mapTo(valueParameters) { + valueParameters += invokeFunctionDescriptor.valueParameters.map { IrValueParameterImpl( SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, invokeFunctionOrigin, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt index 92714f686d0..286b14e361b 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Context.kt @@ -170,9 +170,9 @@ internal class SpecialDeclarationsFactory(val context: Context) : KotlinMangler dispatchReceiverParameter = dispatchReceiver?.copyTo(this) extensionReceiverParameter = extensionReceiver?.copyTo(this) - function.valueParameters.mapTo(valueParameters) { it.copyTo(this, type = valueParameterTypes[it.index]) } + valueParameters += function.valueParameters.map { it.copyTo(this, type = valueParameterTypes[it.index]) } - function.typeParameters.mapIndexedTo(typeParameters) { index, parameter -> + typeParameters += function.typeParameters.mapIndexed { index, parameter -> WrappedTypeParameterDescriptor().let { IrTypeParameterImpl( startOffset, endOffset, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/EntryPoint.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/EntryPoint.kt index b2a6d160417..b5e9722e2f2 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/EntryPoint.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/EntryPoint.kt @@ -44,7 +44,7 @@ internal fun makeEntryPoint(context: Context): IrFunction { isFakeOverride = false, isOperator = false ).also { function -> - function.valueParameters.add(WrappedValueParameterDescriptor().let { + function.valueParameters = listOf(WrappedValueParameterDescriptor().let { IrValueParameterImpl( actualMain.startOffset, actualMain.startOffset, IrDeclarationOrigin.DEFINED, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt index 94d58f4649b..29a5429f87a 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt @@ -1290,7 +1290,7 @@ private class ObjCBlockPointerValuePassing( irClass.addChild(invokeMethod) invokeMethod.createDispatchReceiverParameter() - (0 until parameterCount).mapTo(invokeMethod.valueParameters) { index -> + invokeMethod.valueParameters += (0 until parameterCount).map { index -> val parameterDescriptor = WrappedValueParameterDescriptor() val parameter = IrValueParameterImpl( startOffset, endOffset, diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/KonanIr.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/KonanIr.kt index c830804439d..572f650cefe 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/KonanIr.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/KonanIr.kt @@ -97,8 +97,9 @@ class IrFileImpl(entry: SourceManager.FileEntry) : IrFile { override val metadata: MetadataSource.File? get() = TODO("not implemented") - override val annotations: MutableList + override var annotations: List get() = TODO("not implemented") + set(_) = TODO("not implemented") override val fqName: FqName get() = TODO("not implemented") override val symbol: IrFileSymbol diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/DescriptorToIrTranslationUtils.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/DescriptorToIrTranslationUtils.kt index 139f577153d..a9f842e53b7 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/DescriptorToIrTranslationUtils.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/DescriptorToIrTranslationUtils.kt @@ -53,7 +53,7 @@ internal interface DescriptorToIrTranslationMixin { descriptor = descriptor ).also { irClass -> symbolTable.withScope(descriptor) { - descriptor.typeConstructor.supertypes.mapTo(irClass.superTypes) { + irClass.superTypes += descriptor.typeConstructor.supertypes.map { it.toIrType() } irClass.generateAnnotations() diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/cenum/CEnumClassGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/cenum/CEnumClassGenerator.kt index 95cd295045a..ef35fdd8f81 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/cenum/CEnumClassGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/interop/cenum/CEnumClassGenerator.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.impl.IrEnumConstructorCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBodyImpl import org.jetbrains.kotlin.ir.util.* import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name @@ -119,14 +120,14 @@ internal class CEnumClassGenerator( SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, IrDeclarationOrigin.IR_EXTERNAL_DECLARATION_STUB, entryDescriptor ).also { enumEntry -> - enumEntry.initializerExpression = IrEnumConstructorCallImpl( + enumEntry.initializerExpression = IrExpressionBodyImpl(IrEnumConstructorCallImpl( SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, type = irBuiltIns.unitType, symbol = symbolTable.referenceConstructor(enumDescriptor.unsubstitutedPrimaryConstructor!!), typeArgumentsCount = 0 // enums can't be generic ).also { it.putValueArgument(0, extractEnumEntryValue(entryDescriptor)) - } + }) } } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt index eb9a15f058d..6f5398d57c8 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt @@ -509,6 +509,6 @@ private val Context.getLoweredInlineClassConstructor: (IrConstructor) -> IrSimpl ).apply { descriptor.bind(this) parent = irConstructor.parent - irConstructor.valueParameters.mapTo(valueParameters) { it.copyTo(this) } + valueParameters += irConstructor.valueParameters.map { it.copyTo(this) } } } \ No newline at end of file diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt index d425922d067..716b0259da7 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt @@ -268,7 +268,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass parent = functionReferenceClass functionReferenceClass.declarations += this - boundFunctionParameters.mapIndexedTo(valueParameters) { index, parameter -> + valueParameters += boundFunctionParameters.mapIndexed { index, parameter -> parameter.copyTo(this, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index, type = parameter.type.substitute(typeArgumentsMap)) } @@ -328,7 +328,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass this.createDispatchReceiverParameter() - superFunction.valueParameters.mapIndexedTo(valueParameters) { index, parameter -> + valueParameters += superFunction.valueParameters.mapIndexed { index, parameter -> parameter.copyTo(function, DECLARATION_ORIGIN_FUNCTION_REFERENCE_IMPL, index, type = parameter.type.substitute(typeArgumentsMap)) } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumClassLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumClassLowering.kt index a1d9e307837..2a180353459 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumClassLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumClassLowering.kt @@ -222,7 +222,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass { enumEntries .sortedBy { it.name } .map { - val initializer = it.initializerExpression + val initializer = it.initializerExpression?.expression val entryConstructorCall = when { initializer is IrConstructorCall -> initializer @@ -289,7 +289,7 @@ internal class EnumClassLowering(val context: Context) : ClassLoweringPass { dispatchReceiver = irGet(instances) putValueArgument(0, irInt(it.index)) } - val initializer = it.value.initializerExpression!! + val initializer = it.value.initializerExpression!!.expression initializer.setDeclarationsParent(constructor) when { initializer is IrConstructorCall -> +initInstanceCall(instance, initializer) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt index 8a1d0879202..36240c00094 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/EnumConstructorsLowering.kt @@ -153,7 +153,7 @@ internal class EnumConstructorsLowering(val context: Context) : ClassLoweringPas loweredConstructor.valueParameters += createSynthesizedValueParameter(0, "name", context.irBuiltIns.stringType) loweredConstructor.valueParameters += createSynthesizedValueParameter(1, "ordinal", context.irBuiltIns.intType) - constructor.valueParameters.mapTo(loweredConstructor.valueParameters) { + loweredConstructor.valueParameters += constructor.valueParameters.map { it.copyTo(loweredConstructor, index = it.loweredIndex).apply { loweredEnumConstructorParameters[it] = this } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt index 832d1ce9186..1b86086f9b1 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt @@ -262,9 +262,9 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor resultDescriptor.bind(result) result.parent = irClass result.createDispatchReceiverParameter() - constructor.valueParameters.mapTo(result.valueParameters) { it.copyTo(result) } + result.valueParameters += constructor.valueParameters.map { it.copyTo(result) } - result.overriddenSymbols.add(initMethod.symbol) + result.overriddenSymbols += initMethod.symbol result.body = context.createIrBuilder(result.symbol).irBlockBody(result) { +irReturn( @@ -407,7 +407,7 @@ private class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfor } } - parameterTypes.mapIndexedTo(newFunction.valueParameters) { index, type -> + newFunction.valueParameters += parameterTypes.mapIndexed { index, type -> WrappedValueParameterDescriptor().let { IrValueParameterImpl( function.startOffset, function.endOffset,