IR: rename and move deepCopyWithVariables

Rename it to `deepCopyWithoutPatchingParents`, move to
`org.jetbrains.kotlin.ir.util`, make it inline+reified, and extract the
common implementation with `deepCopyWithSymbols` into `deepCopyImpl`.
This commit is contained in:
Alexander Udalov
2024-03-07 14:14:40 +01:00
committed by Space Team
parent 1d38c01afc
commit d5c2aa4c0c
11 changed files with 35 additions and 36 deletions
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.ir.IrBuiltIns
import org.jetbrains.kotlin.ir.builders.*
import org.jetbrains.kotlin.ir.builders.declarations.*
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.deepCopyWithVariables
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrDelegatingConstructorCallImpl
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
@@ -282,7 +281,7 @@ class JvmAnnotationImplementationTransformer(val jvmContext: JvmBackendContext,
fallbackPrimaryCtorParamsMap[propName]?.defaultValue?.takeIf { it.expression !is IrErrorExpression }
else -> null
}
parameter.defaultValue = newDefaultValue?.deepCopyWithVariables()
parameter.defaultValue = newDefaultValue?.deepCopyWithoutPatchingParents()
?.also { if (defaultValueTransformer != null) it.transformChildrenVoid(defaultValueTransformer) }
ctorBody.statements += with(ctorBodyBuilder) {
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.ir.builders.declarations.buildConstructor
import org.jetbrains.kotlin.ir.builders.declarations.buildField
import org.jetbrains.kotlin.ir.builders.declarations.buildFun
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.deepCopyWithVariables
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.types.IrSimpleType
@@ -64,7 +63,7 @@ fun createLeafMfvcNode(
oldBackingField.metadata = null
}.apply {
this.parent = oldBackingField.parent
this.annotations = fieldAnnotations.map { it.deepCopyWithVariables() }
this.annotations = fieldAnnotations.map { it.deepCopyWithoutPatchingParents() }
}
}