From e1d03f6540db30cfdb76af25f0ef468a84f704cd Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Thu, 7 Dec 2023 16:54:46 +0100 Subject: [PATCH] [IR] Mark IrFieldImpl with an opt-in annotation KT-59318 --- .../kotlin/ir/declarations/impl/IrFieldImpl.kt | 3 ++- .../jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt | 10 +++++----- .../kotlin/backend/konan/lower/Autoboxing.kt | 8 +++----- .../kotlin/backend/konan/lower/DelegationLowering.kt | 11 +++++------ .../kotlin/backend/konan/lower/InteropLowering.kt | 10 +++++----- 5 files changed, 20 insertions(+), 22 deletions(-) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt index dfd52b6c834..bfcf5abec6b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFieldImpl.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.ir.declarations.impl import org.jetbrains.kotlin.descriptors.PropertyDescriptor import org.jetbrains.kotlin.descriptors.DescriptorVisibility +import org.jetbrains.kotlin.ir.IrImplementationDetail import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.IrConstructorCall @@ -16,7 +17,7 @@ import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.name.Name -class IrFieldImpl( +class IrFieldImpl @IrImplementationDetail constructor( override val startOffset: Int, override val endOffset: Int, override var origin: IrDeclarationOrigin, diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt index 79069c83119..4e7f762eb5a 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt @@ -1129,16 +1129,16 @@ private class ObjCBlockPointerValuePassing( irClass.superTypes += stubs.irBuiltIns.anyType irClass.superTypes += functionType.makeNotNull() - val blockHolderField = IrFieldImpl( - startOffset, endOffset, + val blockHolderField = context.irFactory.createField( + startOffset, + endOffset, OBJC_BLOCK_FUNCTION_IMPL, - IrFieldSymbolImpl(), Name.identifier("blockHolder"), - stubs.irBuiltIns.anyType, DescriptorVisibilities.PRIVATE, + IrFieldSymbolImpl(), + stubs.irBuiltIns.anyType, isFinal = true, isStatic = false, - isExternal = false ) irClass.addChild(blockHolderField) 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 2c88077dc34..d380a0178cb 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 @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.ir.IrStatement import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.builders.declarations.buildFun import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl import org.jetbrains.kotlin.ir.declarations.impl.IrPropertyImpl import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl @@ -381,16 +380,15 @@ private class InlineClassTransformer(private val context: Context) : IrBuildingT val startOffset = declaration.startOffset val endOffset = declaration.endOffset - val irField = IrFieldImpl( + val irField = context.irFactory.createField( startOffset, endOffset, IrDeclarationOrigin.DEFINED, - IrFieldSymbolImpl(), Name.identifier("value"), - declaration.defaultType, DescriptorVisibilities.PRIVATE, + IrFieldSymbolImpl(), + declaration.defaultType, isFinal = true, - isExternal = false, isStatic = false, ) irField.parent = declaration diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt index b97526b461a..a240c352580 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/DelegationLowering.kt @@ -16,7 +16,6 @@ import org.jetbrains.kotlin.backend.konan.ir.buildSimpleAnnotation import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.ir.builders.* import org.jetbrains.kotlin.ir.declarations.* -import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl import org.jetbrains.kotlin.ir.expressions.* import org.jetbrains.kotlin.ir.expressions.impl.* import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl @@ -70,15 +69,15 @@ internal class PropertyDelegationLowering(val generationState: NativeGenerationS val generatedClasses = mutableListOf() fun kPropertyField(value: IrExpressionBody, id:Int) = - IrFieldImpl( - SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, + context.irFactory.createField( + SYNTHETIC_OFFSET, + SYNTHETIC_OFFSET, DECLARATION_ORIGIN_KPROPERTIES_FOR_DELEGATION, - IrFieldSymbolImpl(), "KPROPERTY${id}".synthesizedName, - value.expression.type, DescriptorVisibilities.PRIVATE, + IrFieldSymbolImpl(), + value.expression.type, isFinal = true, - isExternal = false, isStatic = true, ).apply { parent = irFile diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt index 55049f1bf82..9ccef0983c1 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/InteropLowering.kt @@ -169,15 +169,15 @@ private class InteropLoweringPart1(val generationState: NativeGenerationState) : } private fun IrFile.addTopLevelInitializer(expression: IrExpression, context: KonanBackendContext, threadLocal: Boolean, eager: Boolean) { - val irField = IrFieldImpl( - expression.startOffset, expression.endOffset, + val irField = context.irFactory.createField( + expression.startOffset, + expression.endOffset, IrDeclarationOrigin.DEFINED, - IrFieldSymbolImpl(), "topLevelInitializer${topLevelInitializersCounter++}".synthesizedName, - expression.type, DescriptorVisibilities.PRIVATE, + IrFieldSymbolImpl(), + expression.type, isFinal = true, - isExternal = false, isStatic = true, ).apply { expression.setDeclarationsParent(this)