Drop assertDetached, unneeded ceremony.
This commit is contained in:
committed by
Dmitry Petrov
parent
00093ac901
commit
aee2a58385
-5
@@ -16,17 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.psi2ir.intermediate
|
package org.jetbrains.kotlin.psi2ir.intermediate
|
||||||
|
|
||||||
import org.jetbrains.kotlin.ir.assertDetached
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
import org.jetbrains.kotlin.psi2ir.generators.CallGenerator
|
import org.jetbrains.kotlin.psi2ir.generators.CallGenerator
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
class OnceExpressionValue(val irExpression: IrExpression) : IntermediateValue {
|
class OnceExpressionValue(val irExpression: IrExpression) : IntermediateValue {
|
||||||
init {
|
|
||||||
irExpression.assertDetached()
|
|
||||||
}
|
|
||||||
|
|
||||||
private var instantiated = false
|
private var instantiated = false
|
||||||
|
|
||||||
override fun load(): IrExpression {
|
override fun load(): IrExpression {
|
||||||
|
|||||||
@@ -65,14 +65,6 @@ inline fun <T : IrElement> 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 =
|
fun IrElement.throwNoSuchSlot(slot: Int): Nothing =
|
||||||
throw AssertionError("${this.render()}: no such slot $slot")
|
throw AssertionError("${this.render()}: no such slot $slot")
|
||||||
|
|
||||||
|
|||||||
-1
@@ -34,7 +34,6 @@ class IrAnonymousInitializerImpl(
|
|||||||
override var body: IrBlockBody
|
override var body: IrBlockBody
|
||||||
get() = bodyImpl!!
|
get() = bodyImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
bodyImpl?.detach()
|
bodyImpl?.detach()
|
||||||
bodyImpl = value
|
bodyImpl = value
|
||||||
value.setTreeLocation(this, ANONYMOUS_INITIALIZER_BODY_SLOT)
|
value.setTreeLocation(this, ANONYMOUS_INITIALIZER_BODY_SLOT)
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class IrClassImpl(
|
|||||||
override val members: MutableList<IrDeclaration> = ArrayList()
|
override val members: MutableList<IrDeclaration> = ArrayList()
|
||||||
|
|
||||||
fun addMember(member: IrDeclaration) {
|
fun addMember(member: IrDeclaration) {
|
||||||
member.assertDetached()
|
|
||||||
member.setTreeLocation(this, members.size)
|
member.setTreeLocation(this, members.size)
|
||||||
members.add(member)
|
members.add(member)
|
||||||
}
|
}
|
||||||
@@ -43,7 +42,6 @@ class IrClassImpl(
|
|||||||
|
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
newChild.assertDetached()
|
|
||||||
members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot)
|
members.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot)
|
||||||
members[slot] = newChild.assertCast()
|
members[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
-1
@@ -43,7 +43,6 @@ class IrDelegatedPropertyImpl(
|
|||||||
override var delegate: IrSimpleProperty
|
override var delegate: IrSimpleProperty
|
||||||
get() = delegateImpl!!
|
get() = delegateImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
delegateImpl?.detach()
|
delegateImpl?.detach()
|
||||||
delegateImpl = value
|
delegateImpl = value
|
||||||
value.setTreeLocation(this, DELEGATE_SLOT)
|
value.setTreeLocation(this, DELEGATE_SLOT)
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class IrEnumEntryImpl(
|
|||||||
) : IrDeclarationBase(startOffset, endOffset, origin), IrEnumEntry {
|
) : IrDeclarationBase(startOffset, endOffset, origin), IrEnumEntry {
|
||||||
override var correspondingClass: IrClass? = null
|
override var correspondingClass: IrClass? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, ENUM_ENTRY_CLASS_SLOT)
|
value?.setTreeLocation(this, ENUM_ENTRY_CLASS_SLOT)
|
||||||
@@ -42,7 +41,6 @@ class IrEnumEntryImpl(
|
|||||||
override var initializerExpression: IrExpression
|
override var initializerExpression: IrExpression
|
||||||
get() = initializerExpressionImpl!!
|
get() = initializerExpressionImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
initializerExpressionImpl?.detach()
|
initializerExpressionImpl?.detach()
|
||||||
initializerExpressionImpl = value
|
initializerExpressionImpl = value
|
||||||
value.setTreeLocation(this, ENUM_ENTRY_INITIALIZER_SLOT)
|
value.setTreeLocation(this, ENUM_ENTRY_INITIALIZER_SLOT)
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ class IrFileImpl(
|
|||||||
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
override val declarations: MutableList<IrDeclaration> = ArrayList()
|
||||||
|
|
||||||
fun addDeclaration(declaration: IrDeclaration) {
|
fun addDeclaration(declaration: IrDeclaration) {
|
||||||
declaration.assertDetached()
|
|
||||||
declaration.setTreeLocation(this, declarations.size)
|
declaration.setTreeLocation(this, declarations.size)
|
||||||
declarations.add(declaration)
|
declarations.add(declaration)
|
||||||
}
|
}
|
||||||
@@ -48,7 +47,6 @@ class IrFileImpl(
|
|||||||
declarations.getOrNull(slot)
|
declarations.getOrNull(slot)
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
newChild.assertDetached()
|
|
||||||
declarations.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot)
|
declarations.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot)
|
||||||
declarations[slot] = newChild.assertCast()
|
declarations[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations.impl
|
package org.jetbrains.kotlin.ir.declarations.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
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.IrDeclarationOrigin
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
import org.jetbrains.kotlin.ir.detach
|
import org.jetbrains.kotlin.ir.detach
|
||||||
@@ -36,7 +35,6 @@ abstract class IrFunctionBase(
|
|||||||
defaults[parameter]
|
defaults[parameter]
|
||||||
|
|
||||||
override fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) {
|
override fun putDefault(parameter: ValueParameterDescriptor, expressionBody: IrExpressionBody) {
|
||||||
expressionBody.assertDetached()
|
|
||||||
defaults[parameter]?.detach()
|
defaults[parameter]?.detach()
|
||||||
defaults[parameter] = expressionBody
|
defaults[parameter] = expressionBody
|
||||||
expressionBody.setTreeLocation(this, parameter.index)
|
expressionBody.setTreeLocation(this, parameter.index)
|
||||||
|
|||||||
-1
@@ -39,7 +39,6 @@ abstract class IrGeneralFunctionBase(
|
|||||||
|
|
||||||
final override var body: IrBody? = null
|
final override var body: IrBody? = null
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
newValue?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = newValue
|
field = newValue
|
||||||
newValue?.setTreeLocation(this, FUNCTION_BODY_SLOT)
|
newValue?.setTreeLocation(this, FUNCTION_BODY_SLOT)
|
||||||
|
|||||||
-3
@@ -45,7 +45,6 @@ class IrLocalDelegatedPropertyImpl(
|
|||||||
override var delegate: IrVariable
|
override var delegate: IrVariable
|
||||||
get() = delegateImpl!!
|
get() = delegateImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
delegateImpl?.detach()
|
delegateImpl?.detach()
|
||||||
delegateImpl = value
|
delegateImpl = value
|
||||||
value.setTreeLocation(this, DELEGATE_SLOT)
|
value.setTreeLocation(this, DELEGATE_SLOT)
|
||||||
@@ -55,7 +54,6 @@ class IrLocalDelegatedPropertyImpl(
|
|||||||
override var getter: IrLocalPropertyAccessor
|
override var getter: IrLocalPropertyAccessor
|
||||||
get() = getterImpl!!
|
get() = getterImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
getterImpl?.detach()
|
getterImpl?.detach()
|
||||||
getterImpl = value
|
getterImpl = value
|
||||||
value.setTreeLocation(this, PROPERTY_GETTER_SLOT)
|
value.setTreeLocation(this, PROPERTY_GETTER_SLOT)
|
||||||
@@ -63,7 +61,6 @@ class IrLocalDelegatedPropertyImpl(
|
|||||||
|
|
||||||
override var setter: IrLocalPropertyAccessor? = null
|
override var setter: IrLocalPropertyAccessor? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, PROPERTY_SETTER_SLOT)
|
value?.setTreeLocation(this, PROPERTY_SETTER_SLOT)
|
||||||
|
|||||||
+2
-7
@@ -17,13 +17,10 @@
|
|||||||
package org.jetbrains.kotlin.ir.declarations.impl
|
package org.jetbrains.kotlin.ir.declarations.impl
|
||||||
|
|
||||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.*
|
||||||
import org.jetbrains.kotlin.ir.assertDetached
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
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 org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
@@ -38,13 +35,11 @@ class IrModuleFragmentImpl(
|
|||||||
override val files: MutableList<IrFile> = ArrayList()
|
override val files: MutableList<IrFile> = ArrayList()
|
||||||
|
|
||||||
fun addFile(file: IrFile) {
|
fun addFile(file: IrFile) {
|
||||||
file.assertDetached()
|
|
||||||
file.setTreeLocation(this, files.size)
|
file.setTreeLocation(this, files.size)
|
||||||
files.add(file)
|
files.add(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addAll(newFiles: List<IrFile>) {
|
fun addAll(newFiles: List<IrFile>) {
|
||||||
newFiles.forEach { it.assertDetached() }
|
|
||||||
val originalSize = files.size
|
val originalSize = files.size
|
||||||
files.addAll(newFiles)
|
files.addAll(newFiles)
|
||||||
newFiles.forEachIndexed { i, irFile -> irFile.setTreeLocation(this, originalSize + i) }
|
newFiles.forEachIndexed { i, irFile -> irFile.setTreeLocation(this, originalSize + i) }
|
||||||
@@ -54,8 +49,8 @@ class IrModuleFragmentImpl(
|
|||||||
files.getOrNull(slot)
|
files.getOrNull(slot)
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
newChild.assertDetached()
|
|
||||||
files.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot)
|
files.getOrNull(slot)?.detach() ?: throwNoSuchSlot(slot)
|
||||||
|
files[slot] = newChild.assertCast()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ abstract class IrPropertyBase(
|
|||||||
) : IrDeclarationBase(startOffset, endOffset, origin), IrProperty {
|
) : IrDeclarationBase(startOffset, endOffset, origin), IrProperty {
|
||||||
override var getter: IrPropertyGetter? = null
|
override var getter: IrPropertyGetter? = null
|
||||||
set(newGetter) {
|
set(newGetter) {
|
||||||
newGetter?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = newGetter
|
field = newGetter
|
||||||
newGetter?.setTreeLocation(this, PROPERTY_GETTER_SLOT)
|
newGetter?.setTreeLocation(this, PROPERTY_GETTER_SLOT)
|
||||||
@@ -40,7 +39,6 @@ abstract class IrPropertyBase(
|
|||||||
|
|
||||||
override var setter: IrPropertySetter? = null
|
override var setter: IrPropertySetter? = null
|
||||||
set(newSetter) {
|
set(newSetter) {
|
||||||
newSetter?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = newSetter
|
field = newSetter
|
||||||
newSetter?.setTreeLocation(this, PROPERTY_SETTER_SLOT)
|
newSetter?.setTreeLocation(this, PROPERTY_SETTER_SLOT)
|
||||||
|
|||||||
-1
@@ -32,7 +32,6 @@ class IrSimplePropertyImpl(
|
|||||||
) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrSimpleProperty {
|
) : IrPropertyBase(startOffset, endOffset, origin, descriptor), IrSimpleProperty {
|
||||||
override var initializer: IrBody? = valueInitializer
|
override var initializer: IrBody? = valueInitializer
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, INITIALIZER_SLOT)
|
value?.setTreeLocation(this, INITIALIZER_SLOT)
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class IrVariableImpl(
|
|||||||
|
|
||||||
override var initializer: IrExpression? = null
|
override var initializer: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, INITIALIZER_SLOT)
|
value?.setTreeLocation(this, INITIALIZER_SLOT)
|
||||||
|
|||||||
-1
@@ -34,7 +34,6 @@ abstract class IrBackingFieldExpressionBase(
|
|||||||
) : IrDeclarationReferenceBase<PropertyDescriptor>(startOffset, endOffset, type, descriptor), IrBackingFieldExpression {
|
) : IrDeclarationReferenceBase<PropertyDescriptor>(startOffset, endOffset, type, descriptor), IrBackingFieldExpression {
|
||||||
override final var receiver: IrExpression? = null
|
override final var receiver: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, BACKING_FIELD_RECEIVER_SLOT)
|
value?.setTreeLocation(this, BACKING_FIELD_RECEIVER_SLOT)
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOff
|
|||||||
override val statements: MutableList<IrStatement> = ArrayList()
|
override val statements: MutableList<IrStatement> = ArrayList()
|
||||||
|
|
||||||
fun addStatement(statement: IrStatement) {
|
fun addStatement(statement: IrStatement) {
|
||||||
statement.assertDetached()
|
|
||||||
statement.setTreeLocation(this, statements.size)
|
statement.setTreeLocation(this, statements.size)
|
||||||
statements.add(statement)
|
statements.add(statement)
|
||||||
}
|
}
|
||||||
@@ -36,7 +35,6 @@ class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOff
|
|||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot)
|
if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot)
|
||||||
|
|
||||||
newChild.assertDetached()
|
|
||||||
statements[slot].detach()
|
statements[slot].detach()
|
||||||
statements[slot] = newChild.assertCast()
|
statements[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
-3
@@ -27,13 +27,11 @@ abstract class IrContainerExpressionBase(startOffset: Int, endOffset: Int, type:
|
|||||||
override val statements: MutableList<IrStatement> = ArrayList(2)
|
override val statements: MutableList<IrStatement> = ArrayList(2)
|
||||||
|
|
||||||
fun addStatement(statement: IrStatement) {
|
fun addStatement(statement: IrStatement) {
|
||||||
statement.assertDetached()
|
|
||||||
statement.setTreeLocation(this, statements.size)
|
statement.setTreeLocation(this, statements.size)
|
||||||
statements.add(statement)
|
statements.add(statement)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun addAll(newStatements: List<IrStatement>) {
|
fun addAll(newStatements: List<IrStatement>) {
|
||||||
newStatements.forEach { it.assertDetached() }
|
|
||||||
val originalSize = this.statements.size
|
val originalSize = this.statements.size
|
||||||
this.statements.addAll(newStatements)
|
this.statements.addAll(newStatements)
|
||||||
newStatements.forEachIndexed { i, irStatement ->
|
newStatements.forEachIndexed { i, irStatement ->
|
||||||
@@ -47,7 +45,6 @@ abstract class IrContainerExpressionBase(startOffset: Int, endOffset: Int, type:
|
|||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot)
|
if (slot < 0 || slot >= statements.size) throwNoSuchSlot(slot)
|
||||||
|
|
||||||
newChild.assertDetached()
|
|
||||||
statements[slot].detach()
|
statements[slot].detach()
|
||||||
statements[slot] = newChild.assertCast()
|
statements[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
-3
@@ -31,7 +31,6 @@ class IrErrorCallExpressionImpl(
|
|||||||
) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression {
|
) : IrExpressionBase(startOffset, endOffset, type), IrErrorCallExpression {
|
||||||
override var explicitReceiver: IrExpression? = null
|
override var explicitReceiver: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT)
|
value?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT)
|
||||||
@@ -40,7 +39,6 @@ class IrErrorCallExpressionImpl(
|
|||||||
override val arguments: MutableList<IrExpression> = SmartList()
|
override val arguments: MutableList<IrExpression> = SmartList()
|
||||||
|
|
||||||
fun addArgument(argument: IrExpression) {
|
fun addArgument(argument: IrExpression) {
|
||||||
argument.assertDetached()
|
|
||||||
argument.setTreeLocation(this, arguments.size)
|
argument.setTreeLocation(this, arguments.size)
|
||||||
arguments.add(argument)
|
arguments.add(argument)
|
||||||
}
|
}
|
||||||
@@ -60,7 +58,6 @@ class IrErrorCallExpressionImpl(
|
|||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot)
|
if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot)
|
||||||
|
|
||||||
newChild.assertDetached()
|
|
||||||
arguments[slot].detach()
|
arguments[slot].detach()
|
||||||
arguments[slot] = newChild.assertCast()
|
arguments[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
-1
@@ -30,7 +30,6 @@ class IrExpressionBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(sta
|
|||||||
override var expression: IrExpression
|
override var expression: IrExpression
|
||||||
get() = expressionImpl!!
|
get() = expressionImpl!!
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
newValue.assertDetached()
|
|
||||||
expressionImpl?.detach()
|
expressionImpl?.detach()
|
||||||
expressionImpl = newValue
|
expressionImpl = newValue
|
||||||
newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.ir.expressions.impl
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.assertCast
|
import org.jetbrains.kotlin.ir.assertCast
|
||||||
import org.jetbrains.kotlin.ir.assertDetached
|
|
||||||
import org.jetbrains.kotlin.ir.detach
|
import org.jetbrains.kotlin.ir.detach
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGeneralCall
|
import org.jetbrains.kotlin.ir.expressions.IrGeneralCall
|
||||||
@@ -44,7 +43,6 @@ abstract class IrGeneralCallBase(
|
|||||||
if (index >= argumentsByParameterIndex.size) {
|
if (index >= argumentsByParameterIndex.size) {
|
||||||
throw AssertionError("$this: No such argument slot: $index")
|
throw AssertionError("$this: No such argument slot: $index")
|
||||||
}
|
}
|
||||||
valueArgument?.assertDetached()
|
|
||||||
argumentsByParameterIndex[index]?.detach()
|
argumentsByParameterIndex[index]?.detach()
|
||||||
argumentsByParameterIndex[index] = valueArgument
|
argumentsByParameterIndex[index] = valueArgument
|
||||||
valueArgument?.setTreeLocation(this, index)
|
valueArgument?.setTreeLocation(this, index)
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ class IrGetClassImpl(startOffset: Int, endOffset: Int, type: KotlinType) : IrExp
|
|||||||
override var argument: IrExpression
|
override var argument: IrExpression
|
||||||
get() = argumentImpl!!
|
get() = argumentImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
argumentImpl?.detach()
|
argumentImpl?.detach()
|
||||||
argumentImpl = value
|
argumentImpl = value
|
||||||
value.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
value.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.ir.*
|
|||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
import org.jetbrains.kotlin.ir.expressions.IrOperator
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrWhen
|
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.ir.visitors.IrElementVisitor
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
|
|
||||||
@@ -56,7 +55,6 @@ class IrIfThenElseImpl(
|
|||||||
var condition: IrExpression
|
var condition: IrExpression
|
||||||
get() = conditionImpl!!
|
get() = conditionImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
value.detach()
|
value.detach()
|
||||||
conditionImpl = value
|
conditionImpl = value
|
||||||
value.setTreeLocation(this, IF_CONDITION_SLOT)
|
value.setTreeLocation(this, IF_CONDITION_SLOT)
|
||||||
@@ -66,7 +64,6 @@ class IrIfThenElseImpl(
|
|||||||
var thenBranch: IrExpression
|
var thenBranch: IrExpression
|
||||||
get() = thenBranchImpl!!
|
get() = thenBranchImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
value.detach()
|
value.detach()
|
||||||
thenBranchImpl = value
|
thenBranchImpl = value
|
||||||
value.setTreeLocation(this, IF_THEN_SLOT)
|
value.setTreeLocation(this, IF_THEN_SLOT)
|
||||||
@@ -74,7 +71,6 @@ class IrIfThenElseImpl(
|
|||||||
|
|
||||||
override var elseBranch: IrExpression? = null
|
override var elseBranch: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
value?.detach()
|
value?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, IF_ELSE_SLOT)
|
value?.setTreeLocation(this, IF_ELSE_SLOT)
|
||||||
@@ -89,7 +85,6 @@ class IrIfThenElseImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
newChild.assertDetached()
|
|
||||||
when (slot) {
|
when (slot) {
|
||||||
IF_CONDITION_SLOT ->
|
IF_CONDITION_SLOT ->
|
||||||
condition = newChild.assertCast()
|
condition = newChild.assertCast()
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ abstract class IrLoopBase(
|
|||||||
override var condition: IrExpression
|
override var condition: IrExpression
|
||||||
get() = conditionImpl!!
|
get() = conditionImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
conditionImpl?.detach()
|
conditionImpl?.detach()
|
||||||
conditionImpl = value
|
conditionImpl = value
|
||||||
value.setTreeLocation(this, LOOP_CONDITION_SLOT)
|
value.setTreeLocation(this, LOOP_CONDITION_SLOT)
|
||||||
@@ -43,7 +42,6 @@ abstract class IrLoopBase(
|
|||||||
|
|
||||||
override var body: IrExpression? = null
|
override var body: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, LOOP_BODY_SLOT)
|
value?.setTreeLocation(this, LOOP_BODY_SLOT)
|
||||||
|
|||||||
-2
@@ -30,7 +30,6 @@ abstract class IrMemberAccessExpressionBase(
|
|||||||
) : IrExpressionBase(startOffset, endOffset, type), IrMemberAccessExpression {
|
) : IrExpressionBase(startOffset, endOffset, type), IrMemberAccessExpression {
|
||||||
override var dispatchReceiver: IrExpression? = null
|
override var dispatchReceiver: IrExpression? = null
|
||||||
set(newReceiver) {
|
set(newReceiver) {
|
||||||
newReceiver?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = newReceiver
|
field = newReceiver
|
||||||
newReceiver?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT)
|
newReceiver?.setTreeLocation(this, DISPATCH_RECEIVER_SLOT)
|
||||||
@@ -38,7 +37,6 @@ abstract class IrMemberAccessExpressionBase(
|
|||||||
|
|
||||||
override var extensionReceiver: IrExpression? = null
|
override var extensionReceiver: IrExpression? = null
|
||||||
set(newReceiver) {
|
set(newReceiver) {
|
||||||
newReceiver?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = newReceiver
|
field = newReceiver
|
||||||
newReceiver?.setTreeLocation(this, EXTENSION_RECEIVER_SLOT)
|
newReceiver?.setTreeLocation(this, EXTENSION_RECEIVER_SLOT)
|
||||||
|
|||||||
@@ -93,7 +93,6 @@ class IrUnaryPrimitiveImpl private constructor(
|
|||||||
var argument: IrExpression
|
var argument: IrExpression
|
||||||
get() = argumentImpl!!
|
get() = argumentImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
argumentImpl?.detach()
|
argumentImpl?.detach()
|
||||||
argumentImpl = value
|
argumentImpl = value
|
||||||
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
||||||
@@ -139,7 +138,6 @@ class IrBinaryPrimitiveImpl(
|
|||||||
var argument0: IrExpression
|
var argument0: IrExpression
|
||||||
get() = argument0Impl!!
|
get() = argument0Impl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
argument0Impl?.detach()
|
argument0Impl?.detach()
|
||||||
argument0Impl = value
|
argument0Impl = value
|
||||||
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
||||||
@@ -149,7 +147,6 @@ class IrBinaryPrimitiveImpl(
|
|||||||
var argument1: IrExpression
|
var argument1: IrExpression
|
||||||
get() = argument1Impl!!
|
get() = argument1Impl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
argument1Impl?.detach()
|
argument1Impl?.detach()
|
||||||
argument1Impl = value
|
argument1Impl = value
|
||||||
value.setTreeLocation(this, ARGUMENT1_SLOT)
|
value.setTreeLocation(this, ARGUMENT1_SLOT)
|
||||||
|
|||||||
-1
@@ -98,7 +98,6 @@ class IrSetterCallImpl(
|
|||||||
override fun putArgument(index: Int, valueArgument: IrExpression?) {
|
override fun putArgument(index: Int, valueArgument: IrExpression?) {
|
||||||
if (index != SETTER_ARGUMENT_INDEX) return
|
if (index != SETTER_ARGUMENT_INDEX) return
|
||||||
argumentImpl?.detach()
|
argumentImpl?.detach()
|
||||||
valueArgument?.assertDetached()
|
|
||||||
argumentImpl = valueArgument
|
argumentImpl = valueArgument
|
||||||
valueArgument?.setTreeLocation(this, SETTER_ARGUMENT_INDEX)
|
valueArgument?.setTreeLocation(this, SETTER_ARGUMENT_INDEX)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ class IrReturnImpl(
|
|||||||
|
|
||||||
override var value: IrExpression? = null
|
override var value: IrExpression? = null
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
newValue?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = newValue
|
field = newValue
|
||||||
newValue?.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
newValue?.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
||||||
|
|||||||
-1
@@ -50,7 +50,6 @@ class IrSetBackingFieldImpl(
|
|||||||
override var value: IrExpression
|
override var value: IrExpression
|
||||||
get() = valueImpl!!
|
get() = valueImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
valueImpl?.detach()
|
valueImpl?.detach()
|
||||||
valueImpl = value
|
valueImpl = value
|
||||||
value.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
value.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ class IrSetVariableImpl(
|
|||||||
override var value: IrExpression
|
override var value: IrExpression
|
||||||
get() = valueImpl!!
|
get() = valueImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
valueImpl?.detach()
|
valueImpl?.detach()
|
||||||
valueImpl = value
|
valueImpl = value
|
||||||
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
||||||
|
|||||||
-1
@@ -33,7 +33,6 @@ class IrSpreadElementImpl(
|
|||||||
override var expression: IrExpression
|
override var expression: IrExpression
|
||||||
get() = expressionImpl!!
|
get() = expressionImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
expressionImpl?.detach()
|
expressionImpl?.detach()
|
||||||
expressionImpl = value
|
expressionImpl = value
|
||||||
value.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
value.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
||||||
|
|||||||
-2
@@ -32,7 +32,6 @@ class IrStringConcatenationImpl(
|
|||||||
override val arguments: MutableList<IrExpression> = ArrayList()
|
override val arguments: MutableList<IrExpression> = ArrayList()
|
||||||
|
|
||||||
override fun addArgument(argument: IrExpression) {
|
override fun addArgument(argument: IrExpression) {
|
||||||
argument.assertDetached()
|
|
||||||
argument.setTreeLocation(this, arguments.size)
|
argument.setTreeLocation(this, arguments.size)
|
||||||
arguments.add(argument)
|
arguments.add(argument)
|
||||||
}
|
}
|
||||||
@@ -43,7 +42,6 @@ class IrStringConcatenationImpl(
|
|||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot)
|
if (slot < 0 || slot >= arguments.size) throwNoSuchSlot(slot)
|
||||||
|
|
||||||
newChild.assertDetached()
|
|
||||||
arguments[slot].detach()
|
arguments[slot].detach()
|
||||||
arguments[slot] = newChild.assertCast()
|
arguments[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ class IrThrowImpl(
|
|||||||
override var value: IrExpression
|
override var value: IrExpression
|
||||||
get() = valueImpl!!
|
get() = valueImpl!!
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
newValue.assertDetached()
|
|
||||||
valueImpl?.detach()
|
valueImpl?.detach()
|
||||||
valueImpl = newValue
|
valueImpl = newValue
|
||||||
newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
newValue.setTreeLocation(this, CHILD_EXPRESSION_SLOT)
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ class IrTryCatchImpl(
|
|||||||
override var tryResult: IrExpression
|
override var tryResult: IrExpression
|
||||||
get() = tryResultImpl!!
|
get() = tryResultImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
tryResultImpl?.detach()
|
tryResultImpl?.detach()
|
||||||
tryResultImpl = value
|
tryResultImpl = value
|
||||||
value.setTreeLocation(this, TRY_RESULT_SLOT)
|
value.setTreeLocation(this, TRY_RESULT_SLOT)
|
||||||
@@ -46,7 +45,6 @@ class IrTryCatchImpl(
|
|||||||
override val catchClausesCount: Int get() = catchClauseResults.size
|
override val catchClausesCount: Int get() = catchClauseResults.size
|
||||||
|
|
||||||
fun addCatchClause(parameter: VariableDescriptor, result: IrExpression) {
|
fun addCatchClause(parameter: VariableDescriptor, result: IrExpression) {
|
||||||
result.assertDetached()
|
|
||||||
result.setTreeLocation(this, catchClausesCount)
|
result.setTreeLocation(this, catchClausesCount)
|
||||||
catchClauseParameters.add(parameter)
|
catchClauseParameters.add(parameter)
|
||||||
catchClauseResults.add(result)
|
catchClauseResults.add(result)
|
||||||
@@ -60,7 +58,6 @@ class IrTryCatchImpl(
|
|||||||
|
|
||||||
override var finallyExpression: IrExpression? = null
|
override var finallyExpression: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
field?.detach()
|
field?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, FINALLY_EXPRESSION_SLOT)
|
value?.setTreeLocation(this, FINALLY_EXPRESSION_SLOT)
|
||||||
|
|||||||
-1
@@ -46,7 +46,6 @@ class IrTypeOperatorCallImpl(
|
|||||||
override var argument: IrExpression
|
override var argument: IrExpression
|
||||||
get() = argumentImpl!!
|
get() = argumentImpl!!
|
||||||
set(value) {
|
set(value) {
|
||||||
value.assertDetached()
|
|
||||||
argumentImpl?.detach()
|
argumentImpl?.detach()
|
||||||
argumentImpl = value
|
argumentImpl = value
|
||||||
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
value.setTreeLocation(this, ARGUMENT0_SLOT)
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ class IrVarargImpl(
|
|||||||
override val elements: MutableList<IrVarargElement> = SmartList()
|
override val elements: MutableList<IrVarargElement> = SmartList()
|
||||||
|
|
||||||
fun addElement(varargElement: IrVarargElement) {
|
fun addElement(varargElement: IrVarargElement) {
|
||||||
varargElement.assertDetached()
|
|
||||||
varargElement.setTreeLocation(this, elements.size)
|
varargElement.setTreeLocation(this, elements.size)
|
||||||
elements.add(varargElement)
|
elements.add(varargElement)
|
||||||
}
|
}
|
||||||
@@ -44,7 +43,6 @@ class IrVarargImpl(
|
|||||||
override fun replaceChild(slot: Int, newChild: IrElement) {
|
override fun replaceChild(slot: Int, newChild: IrElement) {
|
||||||
if (slot < 0 || slot >= elements.size) throwNoSuchSlot(slot)
|
if (slot < 0 || slot >= elements.size) throwNoSuchSlot(slot)
|
||||||
|
|
||||||
newChild.assertDetached()
|
|
||||||
elements[slot].detach()
|
elements[slot].detach()
|
||||||
elements[slot] = newChild.assertCast()
|
elements[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
@@ -34,8 +34,6 @@ class IrWhenImpl(
|
|||||||
private val branchParts = ArrayList<IrExpression>()
|
private val branchParts = ArrayList<IrExpression>()
|
||||||
|
|
||||||
fun addBranch(condition: IrExpression, result: IrExpression) {
|
fun addBranch(condition: IrExpression, result: IrExpression) {
|
||||||
condition.assertDetached()
|
|
||||||
result.assertDetached()
|
|
||||||
condition.setTreeLocation(this, branchParts.size)
|
condition.setTreeLocation(this, branchParts.size)
|
||||||
branchParts.add(condition)
|
branchParts.add(condition)
|
||||||
result.setTreeLocation(this, branchParts.size)
|
result.setTreeLocation(this, branchParts.size)
|
||||||
@@ -44,7 +42,6 @@ class IrWhenImpl(
|
|||||||
|
|
||||||
override var elseBranch: IrExpression? = null
|
override var elseBranch: IrExpression? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
value?.assertDetached()
|
|
||||||
value?.detach()
|
value?.detach()
|
||||||
field = value
|
field = value
|
||||||
value?.setTreeLocation(this, IF_ELSE_SLOT)
|
value?.setTreeLocation(this, IF_ELSE_SLOT)
|
||||||
@@ -61,7 +58,6 @@ class IrWhenImpl(
|
|||||||
when (slot) {
|
when (slot) {
|
||||||
IF_ELSE_SLOT -> elseBranch = newChild.assertCast()
|
IF_ELSE_SLOT -> elseBranch = newChild.assertCast()
|
||||||
in branchParts.indices -> {
|
in branchParts.indices -> {
|
||||||
newChild.assertDetached()
|
|
||||||
branchParts[slot].detach()
|
branchParts[slot].detach()
|
||||||
branchParts[slot] = newChild.assertCast()
|
branchParts[slot] = newChild.assertCast()
|
||||||
newChild.setTreeLocation(this, slot)
|
newChild.setTreeLocation(this, slot)
|
||||||
|
|||||||
Reference in New Issue
Block a user