diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/OnceExpressionValue.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/OnceExpressionValue.kt index 3f081192306..8a690050153 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/OnceExpressionValue.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/intermediate/OnceExpressionValue.kt @@ -16,17 +16,12 @@ package org.jetbrains.kotlin.psi2ir.intermediate -import org.jetbrains.kotlin.ir.assertDetached import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.util.render import org.jetbrains.kotlin.psi2ir.generators.CallGenerator import org.jetbrains.kotlin.types.KotlinType class OnceExpressionValue(val irExpression: IrExpression) : IntermediateValue { - init { - irExpression.assertDetached() - } - private var instantiated = false override fun load(): IrExpression { diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrElement.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrElement.kt index c1f04856961..7a2c3183fb6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrElement.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/IrElement.kt @@ -65,14 +65,6 @@ inline fun T.replaceWith(transformation: (T) -> IrElement) { } } -fun IrElement.assertChild(child: IrElement) { - assert(getChild(child.slot) == child) { "$this: Invalid child: $child" } -} - -fun IrElement.assertDetached() { - assert(parent == null && slot == DETACHED_SLOT) { "$this: should be detached" } -} - fun IrElement.throwNoSuchSlot(slot: Int): Nothing = throw AssertionError("${this.render()}: no such slot $slot") diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt index f4024f991d5..f83aa03da2b 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrAnonymousInitializerImpl.kt @@ -34,7 +34,6 @@ class IrAnonymousInitializerImpl( override var body: IrBlockBody get() = bodyImpl!! set(value) { - value.assertDetached() bodyImpl?.detach() bodyImpl = value value.setTreeLocation(this, ANONYMOUS_INITIALIZER_BODY_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt index 62c569110e4..a38e17b8cb9 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrClassImpl.kt @@ -33,7 +33,6 @@ class IrClassImpl( override val members: MutableList = ArrayList() fun addMember(member: IrDeclaration) { - member.assertDetached() member.setTreeLocation(this, members.size) members.add(member) } @@ -43,7 +42,6 @@ class IrClassImpl( override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) members[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt index cf025c0439c..9fa0f87253e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrDelegatedPropertyImpl.kt @@ -43,7 +43,6 @@ class IrDelegatedPropertyImpl( override var delegate: IrSimpleProperty get() = delegateImpl!! set(value) { - value.assertDetached() delegateImpl?.detach() delegateImpl = value value.setTreeLocation(this, DELEGATE_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt index febcce1364f..2179524abf6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrEnumEntryImpl.kt @@ -32,7 +32,6 @@ class IrEnumEntryImpl( ) : IrDeclarationBase(startOffset, endOffset, origin), IrEnumEntry { override var correspondingClass: IrClass? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, ENUM_ENTRY_CLASS_SLOT) @@ -42,7 +41,6 @@ class IrEnumEntryImpl( override var initializerExpression: IrExpression get() = initializerExpressionImpl!! set(value) { - value.assertDetached() initializerExpressionImpl?.detach() initializerExpressionImpl = value value.setTreeLocation(this, ENUM_ENTRY_INITIALIZER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt index d9de588d64b..b1e974821f8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFileImpl.kt @@ -39,7 +39,6 @@ class IrFileImpl( override val declarations: MutableList = ArrayList() fun addDeclaration(declaration: IrDeclaration) { - declaration.assertDetached() declaration.setTreeLocation(this, declarations.size) declarations.add(declaration) } @@ -48,7 +47,6 @@ class IrFileImpl( declarations.getOrNull(slot) override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() declarations.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) declarations[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt index 0f8bacb6b25..a2244f9d314 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrFunctionBase.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.ir.declarations.impl import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor -import org.jetbrains.kotlin.ir.assertDetached import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.detach @@ -36,7 +35,6 @@ abstract class IrFunctionBase( defaults[parameter] override fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) { - expressionBody.assertDetached() defaults[parameter]?.detach() defaults[parameter] = expressionBody expressionBody.setTreeLocation(this, parameter.index) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt index 63bc1baff65..30be3ee43e5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrGeneralFunctionBase.kt @@ -39,7 +39,6 @@ abstract class IrGeneralFunctionBase( final override var body: IrBody? = null set(newValue) { - newValue?.assertDetached() field?.detach() field = newValue newValue?.setTreeLocation(this, FUNCTION_BODY_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt index f6a418731f8..82134352b14 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrLocalDelegatedPropertyImpl.kt @@ -45,7 +45,6 @@ class IrLocalDelegatedPropertyImpl( override var delegate: IrVariable get() = delegateImpl!! set(value) { - value.assertDetached() delegateImpl?.detach() delegateImpl = value value.setTreeLocation(this, DELEGATE_SLOT) @@ -55,7 +54,6 @@ class IrLocalDelegatedPropertyImpl( override var getter: IrLocalPropertyAccessor get() = getterImpl!! set(value) { - value.assertDetached() getterImpl?.detach() getterImpl = value value.setTreeLocation(this, PROPERTY_GETTER_SLOT) @@ -63,7 +61,6 @@ class IrLocalDelegatedPropertyImpl( override var setter: IrLocalPropertyAccessor? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, PROPERTY_SETTER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleFragmentImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleFragmentImpl.kt index 3da80365a5c..f20b1f54abb 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleFragmentImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrModuleFragmentImpl.kt @@ -17,13 +17,10 @@ package org.jetbrains.kotlin.ir.declarations.impl import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.ir.IrElement -import org.jetbrains.kotlin.ir.assertDetached +import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns -import org.jetbrains.kotlin.ir.detach -import org.jetbrains.kotlin.ir.throwNoSuchSlot import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import java.util.* @@ -38,13 +35,11 @@ class IrModuleFragmentImpl( override val files: MutableList = ArrayList() fun addFile(file: IrFile) { - file.assertDetached() file.setTreeLocation(this, files.size) files.add(file) } fun addAll(newFiles: List) { - newFiles.forEach { it.assertDetached() } val originalSize = files.size files.addAll(newFiles) newFiles.forEachIndexed { i, irFile -> irFile.setTreeLocation(this, originalSize + i) } @@ -54,8 +49,8 @@ class IrModuleFragmentImpl( files.getOrNull(slot) override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() files.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot) + files[slot] = newChild.assertCast() } override fun accept(visitor: IrElementVisitor, data: D): R = diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt index b0b0fdedd23..f3e78fc0be5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrPropertyBase.kt @@ -32,7 +32,6 @@ abstract class IrPropertyBase( ) : IrDeclarationBase(startOffset, endOffset, origin), IrProperty { override var getter: IrPropertyGetter? = null set(newGetter) { - newGetter?.assertDetached() field?.detach() field = newGetter newGetter?.setTreeLocation(this, PROPERTY_GETTER_SLOT) @@ -40,7 +39,6 @@ abstract class IrPropertyBase( override var setter: IrPropertySetter? = null set(newSetter) { - newSetter?.assertDetached() field?.detach() field = newSetter newSetter?.setTreeLocation(this, PROPERTY_SETTER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt index 348340ac0d0..3be639bb5dc 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrSimplePropertyImpl.kt @@ -32,7 +32,6 @@ class IrSimplePropertyImpl( ) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrSimpleProperty { override var initializer: IrBody? = valueInitializer set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, INITIALIZER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt index bbbed51cc34..35bd5eec784 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/declarations/impl/IrVariableImpl.kt @@ -42,7 +42,6 @@ class IrVariableImpl( override var initializer: IrExpression? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, INITIALIZER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt index 0df15e43bc8..f48a6bd6cfc 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBackingFieldExpressionBase.kt @@ -34,7 +34,6 @@ abstract class IrBackingFieldExpressionBase( ) : IrDeclarationReferenceBase(startOffset, endOffset, type, descriptor), IrBackingFieldExpression { override final var receiver: IrExpression? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, BACKING_FIELD_RECEIVER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt index 7abab877499..a13876a6e32 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrBlockBodyImpl.kt @@ -25,7 +25,6 @@ class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOff override val statements: MutableList = ArrayList() fun addStatement(statement: IrStatement) { - statement.assertDetached() statement.setTreeLocation(this, statements.size) statements.add(statement) } @@ -36,7 +35,6 @@ class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOff override fun replaceChild(slot: Int, newChild: IrElement) { if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) - newChild.assertDetached() statements[slot].detach() statements[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt index 2191e669196..b7721b242e5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrContainerExpressionBase.kt @@ -27,13 +27,11 @@ abstract class IrContainerExpressionBase(startOffset: Int, endOffset: Int, type: override val statements: MutableList = ArrayList(2) fun addStatement(statement: IrStatement) { - statement.assertDetached() statement.setTreeLocation(this, statements.size) statements.add(statement) } fun addAll(newStatements: List) { - newStatements.forEach { it.assertDetached() } val originalSize = this.statements.size this.statements.addAll(newStatements) newStatements.forEachIndexed { i, irStatement -> @@ -47,7 +45,6 @@ abstract class IrContainerExpressionBase(startOffset: Int, endOffset: Int, type: override fun replaceChild(slot: Int, newChild: IrElement) { if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot) - newChild.assertDetached() statements[slot].detach() statements[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt index 4ffc869f8e9..c3c78ddb119 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrErrorCallExpressionImpl.kt @@ -31,7 +31,6 @@ class IrErrorCallExpressionImpl( ) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression { override var explicitReceiver: IrExpression? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT) @@ -40,7 +39,6 @@ class IrErrorCallExpressionImpl( override val arguments: MutableList = SmartList() fun addArgument(argument: IrExpression) { - argument.assertDetached() argument.setTreeLocation(this, arguments.size) arguments.add(argument) } @@ -60,7 +58,6 @@ class IrErrorCallExpressionImpl( override fun replaceChild(slot: Int, newChild: IrElement) { if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot) - newChild.assertDetached() arguments[slot].detach() arguments[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt index 76959147878..0b83613c367 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrExpressionBodyImpl.kt @@ -30,7 +30,6 @@ class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(sta override var expression: IrExpression get() = expressionImpl!! set(newValue) { - newValue.assertDetached() expressionImpl?.detach() expressionImpl = newValue newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt index 0564d0222e3..55a8afcb44e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGeneralCallBase.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions.impl import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.assertCast -import org.jetbrains.kotlin.ir.assertDetached import org.jetbrains.kotlin.ir.detach import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrGeneralCall @@ -44,7 +43,6 @@ abstract class IrGeneralCallBase( if (index >= argumentsByParameterIndex.size) { throw AssertionError("$this: No such argument slot: $index") } - valueArgument?.assertDetached() argumentsByParameterIndex[index]?.detach() argumentsByParameterIndex[index] = valueArgument valueArgument?.setTreeLocation(this, index) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt index 4ba1ad2d6d1..d13c63c461e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrGetClassImpl.kt @@ -32,7 +32,6 @@ class IrGetClassImpl(startOffset: Int, endOffset: Int, type: KotlinType) : IrExp override var argument: IrExpression get() = argumentImpl!! set(value) { - value.assertDetached() argumentImpl?.detach() argumentImpl = value value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt index 4c4f5e44187..c694655d621 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrIfThenElseImpl.kt @@ -20,7 +20,6 @@ import org.jetbrains.kotlin.ir.* import org.jetbrains.kotlin.ir.expressions.IrExpression import org.jetbrains.kotlin.ir.expressions.IrOperator import org.jetbrains.kotlin.ir.expressions.IrWhen -import org.jetbrains.kotlin.ir.expressions.impl.IrExpressionBase import org.jetbrains.kotlin.ir.visitors.IrElementVisitor import org.jetbrains.kotlin.types.KotlinType @@ -56,7 +55,6 @@ class IrIfThenElseImpl( var condition: IrExpression get() = conditionImpl!! set(value) { - value.assertDetached() value.detach() conditionImpl = value value.setTreeLocation(this, IF_CONDITION_SLOT) @@ -66,7 +64,6 @@ class IrIfThenElseImpl( var thenBranch: IrExpression get() = thenBranchImpl!! set(value) { - value.assertDetached() value.detach() thenBranchImpl = value value.setTreeLocation(this, IF_THEN_SLOT) @@ -74,7 +71,6 @@ class IrIfThenElseImpl( override var elseBranch: IrExpression? = null set(value) { - value?.assertDetached() value?.detach() field = value value?.setTreeLocation(this, IF_ELSE_SLOT) @@ -89,7 +85,6 @@ class IrIfThenElseImpl( } override fun replaceChild(slot: Int, newChild: IrElement) { - newChild.assertDetached() when (slot) { IF_CONDITION_SLOT -> condition = newChild.assertCast() diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt index bfa40f5c67d..5b74747952f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrLoopBase.kt @@ -35,7 +35,6 @@ abstract class IrLoopBase( override var condition: IrExpression get() = conditionImpl!! set(value) { - value.assertDetached() conditionImpl?.detach() conditionImpl = value value.setTreeLocation(this, LOOP_CONDITION_SLOT) @@ -43,7 +42,6 @@ abstract class IrLoopBase( override var body: IrExpression? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, LOOP_BODY_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt index 13ef0c30faf..0a3ebee3ad8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrMemberAccessExpressionBase.kt @@ -30,7 +30,6 @@ abstract class IrMemberAccessExpressionBase( ) : IrExpressionBase(startOffset, endOffset, type), IrMemberAccessExpression { override var dispatchReceiver: IrExpression? = null set(newReceiver) { - newReceiver?.assertDetached() field?.detach() field = newReceiver newReceiver?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT) @@ -38,7 +37,6 @@ abstract class IrMemberAccessExpressionBase( override var extensionReceiver: IrExpression? = null set(newReceiver) { - newReceiver?.assertDetached() field?.detach() field = newReceiver newReceiver?.setTreeLocation(this, EXTENSION_RECEIVER_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt index 061c5dd7574..154f3443f1e 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPrimitiveCall.kt @@ -93,7 +93,6 @@ class IrUnaryPrimitiveImpl private constructor( var argument: IrExpression get() = argumentImpl!! set(value) { - value.assertDetached() argumentImpl?.detach() argumentImpl = value value.setTreeLocation(this, ARGUMENT0_SLOT) @@ -139,7 +138,6 @@ class IrBinaryPrimitiveImpl( var argument0: IrExpression get() = argument0Impl!! set(value) { - value.assertDetached() argument0Impl?.detach() argument0Impl = value value.setTreeLocation(this, ARGUMENT0_SLOT) @@ -149,7 +147,6 @@ class IrBinaryPrimitiveImpl( var argument1: IrExpression get() = argument1Impl!! set(value) { - value.assertDetached() argument1Impl?.detach() argument1Impl = value value.setTreeLocation(this, ARGUMENT1_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt index ba999abaf6e..76e2af4631c 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrPropertyAccessorCall.kt @@ -98,7 +98,6 @@ class IrSetterCallImpl( override fun putArgument(index: Int, valueArgument: IrExpression?) { if (index != SETTER_ARGUMENT_INDEX) return argumentImpl?.detach() - valueArgument?.assertDetached() argumentImpl = valueArgument valueArgument?.setTreeLocation(this, SETTER_ARGUMENT_INDEX) } diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt index c8fdb3af06d..f01ca05f425 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrReturnImpl.kt @@ -42,7 +42,6 @@ class IrReturnImpl( override var value: IrExpression? = null set(newValue) { - newValue?.assertDetached() field?.detach() field = newValue newValue?.setTreeLocation(this, CHILD_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt index 4ffcd98d7d9..c753464d1b6 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetBackingFieldImpl.kt @@ -50,7 +50,6 @@ class IrSetBackingFieldImpl( override var value: IrExpression get() = valueImpl!! set(value) { - value.assertDetached() valueImpl?.detach() valueImpl = value value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt index 8253e7735c1..2fa20a8528a 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSetVariableImpl.kt @@ -45,7 +45,6 @@ class IrSetVariableImpl( override var value: IrExpression get() = valueImpl!! set(value) { - value.assertDetached() valueImpl?.detach() valueImpl = value value.setTreeLocation(this, ARGUMENT0_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt index 1d7f7812c8e..f8dfef5efe5 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrSpreadElementImpl.kt @@ -33,7 +33,6 @@ class IrSpreadElementImpl( override var expression: IrExpression get() = expressionImpl!! set(value) { - value.assertDetached() expressionImpl?.detach() expressionImpl = value value.setTreeLocation(this, CHILD_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt index c76e0f77b22..c9ce78ceab8 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrStringConcatenationImpl.kt @@ -32,7 +32,6 @@ class IrStringConcatenationImpl( override val arguments: MutableList = ArrayList() override fun addArgument(argument: IrExpression) { - argument.assertDetached() argument.setTreeLocation(this, arguments.size) arguments.add(argument) } @@ -43,7 +42,6 @@ class IrStringConcatenationImpl( override fun replaceChild(slot: Int, newChild: IrElement) { if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot) - newChild.assertDetached() arguments[slot].detach() arguments[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt index 7033ed26e39..a310284a1d4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrThrowImpl.kt @@ -41,7 +41,6 @@ class IrThrowImpl( override var value: IrExpression get() = valueImpl!! set(newValue) { - newValue.assertDetached() valueImpl?.detach() valueImpl = newValue newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt index a4cfac61bf5..f2fc11806f4 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTryCatchImpl.kt @@ -34,7 +34,6 @@ class IrTryCatchImpl( override var tryResult: IrExpression get() = tryResultImpl!! set(value) { - value.assertDetached() tryResultImpl?.detach() tryResultImpl = value value.setTreeLocation(this, TRY_RESULT_SLOT) @@ -46,7 +45,6 @@ class IrTryCatchImpl( override val catchClausesCount: Int get() = catchClauseResults.size fun addCatchClause(parameter: VariableDescriptor, result: IrExpression) { - result.assertDetached() result.setTreeLocation(this, catchClausesCount) catchClauseParameters.add(parameter) catchClauseResults.add(result) @@ -60,7 +58,6 @@ class IrTryCatchImpl( override var finallyExpression: IrExpression? = null set(value) { - value?.assertDetached() field?.detach() field = value value?.setTreeLocation(this, FINALLY_EXPRESSION_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt index 2cd3eb57994..125d2722b48 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrTypeOperatorCallImpl.kt @@ -46,7 +46,6 @@ class IrTypeOperatorCallImpl( override var argument: IrExpression get() = argumentImpl!! set(value) { - value.assertDetached() argumentImpl?.detach() argumentImpl = value value.setTreeLocation(this, ARGUMENT0_SLOT) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt index 18435bc6cbe..65e28aad647 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrVarargImpl.kt @@ -33,7 +33,6 @@ class IrVarargImpl( override val elements: MutableList = SmartList() fun addElement(varargElement: IrVarargElement) { - varargElement.assertDetached() varargElement.setTreeLocation(this, elements.size) elements.add(varargElement) } @@ -44,7 +43,6 @@ class IrVarargImpl( override fun replaceChild(slot: Int, newChild: IrElement) { if (slot < 0 || slot >= elements.size) throwNoSuchSlot(slot) - newChild.assertDetached() elements[slot].detach() elements[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot) diff --git a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt index 226325c1b50..dae9070178f 100644 --- a/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt +++ b/compiler/ir/ir.tree/src/org/jetbrains/kotlin/ir/expressions/impl/IrWhenImpl.kt @@ -34,8 +34,6 @@ class IrWhenImpl( private val branchParts = ArrayList() fun addBranch(condition: IrExpression, result: IrExpression) { - condition.assertDetached() - result.assertDetached() condition.setTreeLocation(this, branchParts.size) branchParts.add(condition) result.setTreeLocation(this, branchParts.size) @@ -44,7 +42,6 @@ class IrWhenImpl( override var elseBranch: IrExpression? = null set(value) { - value?.assertDetached() value?.detach() field = value value?.setTreeLocation(this, IF_ELSE_SLOT) @@ -61,7 +58,6 @@ class IrWhenImpl( when (slot) { IF_ELSE_SLOT -> elseBranch = newChild.assertCast() in branchParts.indices -> { - newChild.assertDetached() branchParts[slot].detach() branchParts[slot] = newChild.assertCast() newChild.setTreeLocation(this, slot)