From 4fb29a5e12e859421ce9d12883ca2fc2318ab005 Mon Sep 17 00:00:00 2001 From: Ivan Kylchik Date: Wed, 16 Aug 2023 11:14:44 +0200 Subject: [PATCH] [Native] Drop `addArguments` from `IrUtils2` We can simplify single usage of this function --- .../jetbrains/kotlin/backend/konan/Boxing.kt | 3 +-- .../kotlin/backend/konan/lower/Autoboxing.kt | 4 +-- .../org/jetbrains/kotlin/ir/util/IrUtils2.kt | 26 ------------------- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt index 75578ff1850..f1fbaf8da1e 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/Boxing.kt @@ -38,11 +38,10 @@ private fun Context.getTypeConversionImpl( if (actualInlinedClass == expectedInlinedClass) return null return when { - actualInlinedClass == null && expectedInlinedClass == null -> null actualInlinedClass != null && expectedInlinedClass == null -> getBoxFunction(actualInlinedClass) actualInlinedClass == null && expectedInlinedClass != null -> getUnboxFunction(expectedInlinedClass) else -> error("actual type is ${actualInlinedClass?.fqNameForIrSerialization}, expected ${expectedInlinedClass?.fqNameForIrSerialization}") - }?.symbol + }.symbol } internal object DECLARATION_ORIGIN_INLINE_CLASS_SPECIAL_FUNCTION : IrDeclarationOriginImpl("INLINE_CLASS_SPECIAL_FUNCTION") diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt index a42448daaf0..35bca24d361 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/Autoboxing.kt @@ -146,12 +146,12 @@ private class AutoboxingTransformer(val context: Context) : AbstractValueUsageTr it.type = expectedType return it } - val parameter = conversion.owner.explicitParameters.single() + val parameter = conversion.owner.valueParameters.single() val argument = this.uncheckedCast(parameter.type) IrCallImpl(startOffset, endOffset, conversion.owner.returnType, conversion, conversion.owner.typeParameters.size, conversion.owner.valueParameters.size).apply { - addArguments(mapOf(parameter to argument)) + this.putValueArgument(parameter.index, argument) }.uncheckedCast(this.type) // Try not to bring new type incompatibilities. } } diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt index 2550ab4f4b5..ee7accd4221 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/ir/util/IrUtils2.kt @@ -68,32 +68,6 @@ fun IrModuleFragment.addFile(fileEntry: IrFileEntry, packageFqName: FqName): IrF .also { this.files += it } } -fun IrFunctionAccessExpression.addArguments(args: Map) { - val unhandledParameters = args.keys.toMutableSet() - fun getArg(parameter: IrValueParameter) = args[parameter]?.also { unhandledParameters -= parameter } - - symbol.owner.dispatchReceiverParameter?.let { - val arg = getArg(it) - if (arg != null) { - this.dispatchReceiver = arg - } - } - - symbol.owner.extensionReceiverParameter?.let { - val arg = getArg(it) - if (arg != null) { - this.extensionReceiver = arg - } - } - - symbol.owner.valueParameters.forEach { - val arg = getArg(it) - if (arg != null) { - this.putValueArgument(it.index, arg) - } - } -} - fun IrBuilderWithScope.irCatch() = IrCatchImpl( startOffset, endOffset,