IR: make most properties mutable

This commit is contained in:
Alexander Udalov
2023-02-13 14:53:10 +01:00
committed by Space Team
parent d2938e732a
commit 22b4b29292
94 changed files with 419 additions and 336 deletions
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.lazy
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.fir.FirAnnotationContainer
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
import org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
@@ -38,37 +37,58 @@ abstract class AbstractFir2IrLazyFunction<F : FirCallableDeclaration>(
override val endOffset: Int,
override var origin: IrDeclarationOrigin,
override val symbol: IrSimpleFunctionSymbol,
override val isFakeOverride: Boolean
override var isFakeOverride: Boolean
) : IrSimpleFunction(), AbstractFir2IrLazyDeclaration<F>, Fir2IrTypeParametersContainer, IrLazyFunctionBase,
Fir2IrComponents by components {
override lateinit var typeParameters: List<IrTypeParameter>
override lateinit var parent: IrDeclarationParent
override val isTailrec: Boolean
override var isTailrec: Boolean
get() = fir.isTailRec
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isSuspend: Boolean
override var isSuspend: Boolean
get() = fir.isSuspend
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isOperator: Boolean
override var isOperator: Boolean
get() = fir.isOperator
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isInfix: Boolean
override var isInfix: Boolean
get() = fir.isInfix
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
@ObsoleteDescriptorBasedAPI
override val descriptor: FunctionDescriptor
get() = symbol.descriptor
override val isInline: Boolean
override var isInline: Boolean
get() = fir.isInline
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExternal: Boolean
override var isExternal: Boolean
get() = fir.isExternal
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExpect: Boolean
override var isExpect: Boolean
get() = fir.isExpect
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var body: IrBody? by lazyVar(lock) {
if (tryLoadIr()) body else null
@@ -78,8 +98,11 @@ abstract class AbstractFir2IrLazyFunction<F : FirCallableDeclaration>(
components.visibilityConverter.convertToDescriptorVisibility(fir.visibility)
}
override val modality: Modality
override var modality: Modality
get() = fir.modality!!
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var correspondingPropertySymbol: IrPropertySymbol? = null
@@ -5,7 +5,6 @@
package org.jetbrains.kotlin.fir.lazy
import org.jetbrains.kotlin.KtFakeSourceElementKind
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.fir.backend.*
import org.jetbrains.kotlin.fir.declarations.*
@@ -83,29 +82,53 @@ class Fir2IrLazyClass(
error("Mutating Fir2Ir lazy elements is not possible")
}
override val kind: ClassKind
override var kind: ClassKind
get() = fir.classKind
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isCompanion: Boolean
override var isCompanion: Boolean
get() = fir.isCompanion
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isInner: Boolean
override var isInner: Boolean
get() = fir.isInner
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isData: Boolean
override var isData: Boolean
get() = fir.isData
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExternal: Boolean
override var isExternal: Boolean
get() = fir.isExternal
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isValue: Boolean
override var isValue: Boolean
get() = fir.isInline
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExpect: Boolean
override var isExpect: Boolean
get() = fir.isExpect
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isFun: Boolean
override var isFun: Boolean
get() = fir.isFun
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var superTypes: List<IrType> by lazyVar(lock) {
fir.superTypeRefs.map { it.toIrType(typeConverter) }
@@ -46,21 +46,33 @@ class Fir2IrLazyConstructor(
override lateinit var typeParameters: List<IrTypeParameter>
override lateinit var parent: IrDeclarationParent
override val isPrimary: Boolean
override var isPrimary: Boolean
get() = fir.isPrimary
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
@ObsoleteDescriptorBasedAPI
override val descriptor: ClassConstructorDescriptor
get() = symbol.descriptor
override val isInline: Boolean
override var isInline: Boolean
get() = fir.isInline
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExternal: Boolean
override var isExternal: Boolean
get() = fir.isExternal
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExpect: Boolean
override var isExpect: Boolean
get() = fir.isExpect
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var body: IrBody? = null
@@ -39,7 +39,7 @@ class Fir2IrLazyProperty(
override val fir: FirProperty,
val containingClass: FirRegularClass?,
override val symbol: Fir2IrPropertySymbol,
override val isFakeOverride: Boolean
override var isFakeOverride: Boolean
) : IrProperty(), AbstractFir2IrLazyDeclaration<FirProperty>, Fir2IrComponents by components {
init {
symbol.bind(this)
@@ -53,23 +53,41 @@ class Fir2IrLazyProperty(
override val descriptor: PropertyDescriptor
get() = symbol.descriptor
override val isVar: Boolean
override var isVar: Boolean
get() = fir.isVar
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isConst: Boolean
override var isConst: Boolean
get() = fir.isConst
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isLateinit: Boolean
override var isLateinit: Boolean
get() = fir.isLateInit
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isDelegated: Boolean
override var isDelegated: Boolean
get() = fir.delegate != null
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExternal: Boolean
override var isExternal: Boolean
get() = fir.isExternal
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override val isExpect: Boolean
override var isExpect: Boolean
get() = fir.isExpect
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var name: Name
get() = fir.name
@@ -83,8 +101,11 @@ class Fir2IrLazyProperty(
error("Mutating Fir2Ir lazy elements is not possible")
}
override val modality: Modality
override var modality: Modality
get() = fir.modality!!
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
private val type: IrType by lazy {
with(typeConverter) { fir.returnTypeRef.toIrType() }
@@ -44,8 +44,11 @@ class Fir2IrLazyPropertyAccessor(
get() = firAccessor ?: firParentProperty
// TODO: investigate why some deserialized properties are inline
override val isInline: Boolean
override var isInline: Boolean
get() = firAccessor?.isInline == true
set(_) {
error("Mutating Fir2Ir lazy elements is not possible")
}
override var annotations: List<IrConstructorCall> by createLazyAnnotations()
@@ -655,7 +655,7 @@ class FunctionInlining(
private class IrGetValueWithoutLocation(
override val symbol: IrValueSymbol,
override val origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin? = null
) : IrGetValue() {
override val startOffset: Int get() = UNDEFINED_OFFSET
override val endOffset: Int get() = UNDEFINED_OFFSET
@@ -25,7 +25,7 @@ abstract class IrAnonymousInitializer : IrDeclarationBase() {
abstract override val symbol: IrAnonymousInitializerSymbol
abstract val isStatic: Boolean
abstract var isStatic: Boolean
abstract var body: IrBlockBody
@@ -34,21 +34,21 @@ abstract class IrClass : IrDeclarationBase(), IrPossiblyExternalDeclaration,
abstract override val symbol: IrClassSymbol
abstract val kind: ClassKind
abstract var kind: ClassKind
abstract var modality: Modality
abstract val isCompanion: Boolean
abstract var isCompanion: Boolean
abstract val isInner: Boolean
abstract var isInner: Boolean
abstract val isData: Boolean
abstract var isData: Boolean
abstract val isValue: Boolean
abstract var isValue: Boolean
abstract val isExpect: Boolean
abstract var isExpect: Boolean
abstract val isFun: Boolean
abstract var isFun: Boolean
abstract val source: SourceElement
@@ -23,7 +23,7 @@ abstract class IrConstructor : IrFunction() {
abstract override val symbol: IrConstructorSymbol
abstract val isPrimary: Boolean
abstract var isPrimary: Boolean
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitConstructor(this, data)
@@ -30,9 +30,9 @@ abstract class IrField : IrDeclarationBase(), IrPossiblyExternalDeclaration,
abstract var type: IrType
abstract val isFinal: Boolean
abstract var isFinal: Boolean
abstract val isStatic: Boolean
abstract var isStatic: Boolean
abstract var initializer: IrExpressionBody?
@@ -22,9 +22,9 @@ abstract class IrFile : IrPackageFragment(), IrMetadataSourceOwner,
IrMutableAnnotationContainer {
abstract override val symbol: IrFileSymbol
abstract val module: IrModuleFragment
abstract var module: IrModuleFragment
abstract val fileEntry: IrFileEntry
abstract var fileEntry: IrFileEntry
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitFile(this, data)
@@ -29,9 +29,9 @@ abstract class IrFunction : IrDeclarationBase(), IrPossiblyExternalDeclaration,
abstract override val symbol: IrFunctionSymbol
abstract val isInline: Boolean
abstract var isInline: Boolean
abstract val isExpect: Boolean
abstract var isExpect: Boolean
abstract var returnType: IrType
@@ -28,7 +28,7 @@ abstract class IrLocalDelegatedProperty : IrDeclarationBase(), IrDeclarationWith
abstract var type: IrType
abstract val isVar: Boolean
abstract var isVar: Boolean
abstract var delegate: IrVariable
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSymbol
interface IrOverridableDeclaration<S : IrSymbol> : IrOverridableMember {
override val symbol: S
val isFakeOverride: Boolean
var isFakeOverride: Boolean
var overriddenSymbols: List<S>
}
@@ -16,5 +16,5 @@ import org.jetbrains.kotlin.descriptors.Modality
*/
interface IrOverridableMember : IrDeclaration, IrDeclarationWithVisibility,
IrDeclarationWithName, IrSymbolOwner {
val modality: Modality
var modality: Modality
}
@@ -24,5 +24,5 @@ abstract class IrPackageFragment : IrElementBase(), IrDeclarationContainer, IrSy
@ObsoleteDescriptorBasedAPI
abstract val packageFragmentDescriptor: PackageFragmentDescriptor
abstract val fqName: FqName
abstract var fqName: FqName
}
@@ -14,5 +14,5 @@ package org.jetbrains.kotlin.ir.declarations
* @sample org.jetbrains.kotlin.ir.generator.IrTree.possiblyExternalDeclaration
*/
interface IrPossiblyExternalDeclaration : IrDeclarationWithName {
val isExternal: Boolean
var isExternal: Boolean
}
@@ -26,17 +26,17 @@ abstract class IrProperty : IrDeclarationBase(), IrPossiblyExternalDeclaration,
abstract override val symbol: IrPropertySymbol
abstract val isVar: Boolean
abstract var isVar: Boolean
abstract val isConst: Boolean
abstract var isConst: Boolean
abstract val isLateinit: Boolean
abstract var isLateinit: Boolean
abstract val isDelegated: Boolean
abstract var isDelegated: Boolean
abstract val isExpect: Boolean
abstract var isExpect: Boolean
abstract override val isFakeOverride: Boolean
abstract override var isFakeOverride: Boolean
abstract var backingField: IrField?
@@ -20,15 +20,15 @@ abstract class IrSimpleFunction : IrFunction(),
IrOverridableDeclaration<IrSimpleFunctionSymbol>, IrAttributeContainer {
abstract override val symbol: IrSimpleFunctionSymbol
abstract val isTailrec: Boolean
abstract var isTailrec: Boolean
abstract val isSuspend: Boolean
abstract var isSuspend: Boolean
abstract override val isFakeOverride: Boolean
abstract override var isFakeOverride: Boolean
abstract val isOperator: Boolean
abstract var isOperator: Boolean
abstract val isInfix: Boolean
abstract var isInfix: Boolean
abstract var correspondingPropertySymbol: IrPropertySymbol?
@@ -27,7 +27,7 @@ abstract class IrTypeAlias : IrDeclarationBase(), IrDeclarationWithName,
abstract override val symbol: IrTypeAliasSymbol
abstract val isActual: Boolean
abstract var isActual: Boolean
abstract var expandedType: IrType
@@ -26,11 +26,11 @@ abstract class IrTypeParameter : IrDeclarationBase(), IrDeclarationWithName {
abstract override val symbol: IrTypeParameterSymbol
abstract val variance: Variance
abstract var variance: Variance
abstract val index: Int
abstract var index: Int
abstract val isReified: Boolean
abstract var isReified: Boolean
abstract var superTypes: List<IrType>
@@ -26,15 +26,15 @@ abstract class IrValueParameter : IrDeclarationBase(), IrValueDeclaration {
abstract override val symbol: IrValueParameterSymbol
abstract val index: Int
abstract var index: Int
abstract var varargElementType: IrType?
abstract val isCrossinline: Boolean
abstract var isCrossinline: Boolean
abstract val isNoinline: Boolean
abstract var isNoinline: Boolean
abstract val isHidden: Boolean
abstract var isHidden: Boolean
abstract var defaultValue: IrExpressionBody?
@@ -25,11 +25,11 @@ abstract class IrVariable : IrDeclarationBase(), IrValueDeclaration {
abstract override val symbol: IrVariableSymbol
abstract val isVar: Boolean
abstract var isVar: Boolean
abstract val isConst: Boolean
abstract var isConst: Boolean
abstract val isLateinit: Boolean
abstract var isLateinit: Boolean
abstract var initializer: IrExpression?
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrCall : IrFunctionAccessExpression() {
abstract override val symbol: IrSimpleFunctionSymbol
abstract val superQualifierSymbol: IrClassSymbol?
abstract var superQualifierSymbol: IrClassSymbol?
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitCall(this, data)
@@ -15,9 +15,9 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.const
*/
abstract class IrConst<T> : IrExpression() {
abstract val kind: IrConstKind<T>
abstract var kind: IrConstKind<T>
abstract val value: T
abstract var value: T
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitConst(this, data)
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.constantObject
*/
abstract class IrConstantObject : IrConstantValue() {
abstract val constructor: IrConstructorSymbol
abstract var constructor: IrConstructorSymbol
abstract val valueArguments: MutableList<IrConstantValue>
@@ -19,9 +19,9 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrConstructorCall : IrFunctionAccessExpression() {
abstract override val symbol: IrConstructorSymbol
abstract val source: SourceElement
abstract var source: SourceElement
abstract val constructorTypeArgumentsCount: Int
abstract var constructorTypeArgumentsCount: Int
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitConstructorCall(this, data)
@@ -18,7 +18,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.containerExpression
*/
abstract class IrContainerExpression : IrExpression(), IrStatementContainer {
abstract val origin: IrStatementOrigin?
abstract var origin: IrStatementOrigin?
override val statements: MutableList<IrStatement> = ArrayList(2)
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.dynamicMemberExpression
*/
abstract class IrDynamicMemberExpression : IrDynamicExpression() {
abstract val memberName: String
abstract var memberName: String
abstract var receiver: IrExpression
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.dynamicOperatorExpression
*/
abstract class IrDynamicOperatorExpression : IrDynamicExpression() {
abstract val operator: IrDynamicOperator
abstract var operator: IrDynamicOperator
abstract var receiver: IrExpression
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.errorExpression
*/
abstract class IrErrorExpression : IrExpression() {
abstract val description: String
abstract var description: String
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitErrorExpression(this, data)
@@ -18,9 +18,9 @@ import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
abstract class IrFieldAccessExpression : IrDeclarationReference() {
abstract override val symbol: IrFieldSymbol
abstract val superQualifierSymbol: IrClassSymbol?
abstract var superQualifierSymbol: IrClassSymbol?
var receiver: IrExpression? = null
abstract val origin: IrStatementOrigin?
abstract var origin: IrStatementOrigin?
}
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.functionExpression
*/
abstract class IrFunctionExpression : IrExpression() {
abstract val origin: IrStatementOrigin
abstract var origin: IrStatementOrigin
abstract var function: IrSimpleFunction
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.functionReference
*/
abstract class IrFunctionReference : IrCallableReference<IrFunctionSymbol>() {
abstract val reflectionTarget: IrFunctionSymbol?
abstract var reflectionTarget: IrFunctionSymbol?
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitFunctionReference(this, data)
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.instanceInitializerCall
*/
abstract class IrInstanceInitializerCall : IrExpression() {
abstract val classSymbol: IrClassSymbol
abstract var classSymbol: IrClassSymbol
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitInstanceInitializerCall(this, data)
@@ -19,11 +19,11 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
*/
abstract class IrLocalDelegatedPropertyReference :
IrCallableReference<IrLocalDelegatedPropertySymbol>() {
abstract val delegate: IrVariableSymbol
abstract var delegate: IrVariableSymbol
abstract val getter: IrSimpleFunctionSymbol
abstract var getter: IrSimpleFunctionSymbol
abstract val setter: IrSimpleFunctionSymbol?
abstract var setter: IrSimpleFunctionSymbol?
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitLocalDelegatedPropertyReference(this, data)
@@ -14,7 +14,7 @@ package org.jetbrains.kotlin.ir.expressions
* @sample org.jetbrains.kotlin.ir.generator.IrTree.loop
*/
abstract class IrLoop : IrExpression() {
abstract val origin: IrStatementOrigin?
abstract var origin: IrStatementOrigin?
var body: IrExpression? = null
@@ -18,11 +18,11 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.propertyReference
*/
abstract class IrPropertyReference : IrCallableReference<IrPropertySymbol>() {
abstract val field: IrFieldSymbol?
abstract var field: IrFieldSymbol?
abstract val getter: IrSimpleFunctionSymbol?
abstract var getter: IrSimpleFunctionSymbol?
abstract val setter: IrSimpleFunctionSymbol?
abstract var setter: IrSimpleFunctionSymbol?
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitPropertyReference(this, data)
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
abstract class IrReturn : IrExpression() {
abstract var value: IrExpression
abstract val returnTargetSymbol: IrReturnTargetSymbol
abstract var returnTargetSymbol: IrReturnTargetSymbol
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitReturn(this, data)
@@ -20,5 +20,5 @@ import org.jetbrains.kotlin.ir.symbols.IrReturnableBlockSymbol
abstract class IrReturnableBlock : IrBlock(), IrSymbolOwner, IrReturnTarget {
abstract override val symbol: IrReturnableBlockSymbol
abstract val inlineFunctionSymbol: IrFunctionSymbol?
abstract var inlineFunctionSymbol: IrFunctionSymbol?
}
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.syntheticBody
*/
abstract class IrSyntheticBody : IrBody() {
abstract val kind: IrSyntheticBodyKind
abstract var kind: IrSyntheticBodyKind
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
visitor.visitSyntheticBody(this, data)
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.typeOperatorCall
*/
abstract class IrTypeOperatorCall : IrExpression() {
abstract val operator: IrTypeOperator
abstract var operator: IrTypeOperator
abstract var argument: IrExpression
@@ -17,5 +17,5 @@ import org.jetbrains.kotlin.ir.symbols.IrValueSymbol
abstract class IrValueAccessExpression : IrDeclarationReference() {
abstract override val symbol: IrValueSymbol
abstract val origin: IrStatementOrigin?
abstract var origin: IrStatementOrigin?
}
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
* @sample org.jetbrains.kotlin.ir.generator.IrTree.when
*/
abstract class IrWhen : IrExpression() {
abstract val origin: IrStatementOrigin?
abstract var origin: IrStatementOrigin?
abstract val branches: MutableList<IrBranch>
@@ -20,7 +20,7 @@ class IrAnonymousInitializerImpl(
override val endOffset: Int,
override var origin: IrDeclarationOrigin,
override val symbol: IrAnonymousInitializerSymbol,
override val isStatic: Boolean = false,
override var isStatic: Boolean = false,
override val factory: IrFactory = IrFactoryImpl,
) : IrAnonymousInitializer() {
init {
@@ -20,16 +20,16 @@ open class IrClassImpl(
override var origin: IrDeclarationOrigin,
final override val symbol: IrClassSymbol,
override var name: Name,
override val kind: ClassKind,
override var kind: ClassKind,
override var visibility: DescriptorVisibility,
override var modality: Modality,
override val isCompanion: Boolean = false,
override var isCompanion: Boolean = false,
override var isInner: Boolean = false,
override val isData: Boolean = false,
override val isExternal: Boolean = false,
override val isValue: Boolean = false,
override val isExpect: Boolean = false,
override val isFun: Boolean = false,
override var isData: Boolean = false,
override var isExternal: Boolean = false,
override var isValue: Boolean = false,
override var isExpect: Boolean = false,
override var isFun: Boolean = false,
override val source: SourceElement = SourceElement.NO_SOURCE,
override val factory: IrFactory = IrFactoryImpl
) : IrClass() {
@@ -26,11 +26,11 @@ class IrConstructorImpl(
override var name: Name,
override var visibility: DescriptorVisibility,
returnType: IrType,
override val isInline: Boolean,
override val isExternal: Boolean,
override val isPrimary: Boolean,
override val isExpect: Boolean,
override val containerSource: DeserializedContainerSource? = null,
override var isInline: Boolean,
override var isExternal: Boolean,
override var isPrimary: Boolean,
override var isExpect: Boolean,
override var containerSource: DeserializedContainerSource? = null,
override val factory: IrFactory = IrFactoryImpl,
) : IrConstructor() {
init {
@@ -31,7 +31,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
class IrExternalPackageFragmentImpl(
override val symbol: IrExternalPackageFragmentSymbol,
override val fqName: FqName
override var fqName: FqName
) : IrExternalPackageFragment() {
override val startOffset: Int
get() = UNDEFINED_OFFSET
@@ -24,9 +24,9 @@ class IrFieldImpl(
override var name: Name,
override var type: IrType,
override var visibility: DescriptorVisibility,
override val isFinal: Boolean,
override val isExternal: Boolean,
override val isStatic: Boolean,
override var isFinal: Boolean,
override var isExternal: Boolean,
override var isStatic: Boolean,
override val factory: IrFactory = IrFactoryImpl,
) : IrField() {
init {
@@ -29,9 +29,9 @@ import org.jetbrains.kotlin.ir.symbols.impl.IrFileSymbolImpl
import org.jetbrains.kotlin.name.FqName
class IrFileImpl(
override val fileEntry: IrFileEntry,
override var fileEntry: IrFileEntry,
override val symbol: IrFileSymbol,
override val fqName: FqName
override var fqName: FqName
) : IrFile() {
constructor(
fileEntry: IrFileEntry,
@@ -28,14 +28,14 @@ abstract class IrFunctionCommonImpl(
override var name: Name,
override var visibility: DescriptorVisibility,
returnType: IrType,
override val isInline: Boolean,
override val isExternal: Boolean,
override val isTailrec: Boolean,
override val isSuspend: Boolean,
override val isOperator: Boolean,
override val isInfix: Boolean,
override val isExpect: Boolean,
override val containerSource: DeserializedContainerSource?,
override var isInline: Boolean,
override var isExternal: Boolean,
override var isTailrec: Boolean,
override var isSuspend: Boolean,
override var isOperator: Boolean,
override var isInfix: Boolean,
override var isExpect: Boolean,
override var containerSource: DeserializedContainerSource?,
) : IrSimpleFunction() {
override lateinit var parent: IrDeclarationParent
@@ -75,7 +75,7 @@ class IrFunctionImpl(
override val symbol: IrSimpleFunctionSymbol,
name: Name,
visibility: DescriptorVisibility,
override val modality: Modality,
override var modality: Modality,
returnType: IrType,
isInline: Boolean,
isExternal: Boolean,
@@ -84,7 +84,7 @@ class IrFunctionImpl(
isOperator: Boolean,
isInfix: Boolean,
isExpect: Boolean,
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override var isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
containerSource: DeserializedContainerSource? = null,
override val factory: IrFactory = IrFactoryImpl,
) : IrFunctionCommonImpl(
@@ -116,7 +116,7 @@ class IrFunctionWithLateBindingImpl(
isOperator: Boolean,
isInfix: Boolean,
isExpect: Boolean,
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override var isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override val factory: IrFactory = IrFactoryImpl
) : IrFunctionCommonImpl(
startOffset, endOffset, origin, name, visibility, returnType, isInline,
@@ -20,7 +20,7 @@ class IrLocalDelegatedPropertyImpl(
override val symbol: IrLocalDelegatedPropertySymbol,
override var name: Name,
override var type: IrType,
override val isVar: Boolean,
override var isVar: Boolean,
override val factory: IrFactory = IrFactoryImpl,
) : IrLocalDelegatedProperty() {
init {
@@ -5,9 +5,9 @@
package org.jetbrains.kotlin.ir.declarations.impl
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.DescriptorVisibility
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
@@ -22,12 +22,12 @@ abstract class IrPropertyCommonImpl(
override var origin: IrDeclarationOrigin,
override var name: Name,
override var visibility: DescriptorVisibility,
override val isVar: Boolean,
override val isConst: Boolean,
override val isLateinit: Boolean,
override val isDelegated: Boolean,
override val isExternal: Boolean,
override val isExpect: Boolean,
override var isVar: Boolean,
override var isConst: Boolean,
override var isLateinit: Boolean,
override var isDelegated: Boolean,
override var isExternal: Boolean,
override var isExpect: Boolean,
override val containerSource: DeserializedContainerSource?,
) : IrProperty() {
@@ -54,14 +54,14 @@ class IrPropertyImpl(
override val symbol: IrPropertySymbol,
name: Name,
visibility: DescriptorVisibility,
override val modality: Modality,
override var modality: Modality,
isVar: Boolean,
isConst: Boolean,
isLateinit: Boolean,
isDelegated: Boolean,
isExternal: Boolean,
isExpect: Boolean = false,
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override var isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
containerSource: DeserializedContainerSource? = null,
override val factory: IrFactory = IrFactoryImpl,
) : IrPropertyCommonImpl(
@@ -90,7 +90,7 @@ class IrPropertyWithLateBindingImpl(
isDelegated: Boolean,
isExternal: Boolean,
isExpect: Boolean,
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override var isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE,
override val factory: IrFactory = IrFactoryImpl,
) : IrPropertyCommonImpl(
startOffset, endOffset, origin, name, visibility, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect,
@@ -21,7 +21,7 @@ class IrTypeAliasImpl(
override var name: Name,
override var visibility: DescriptorVisibility,
override var expandedType: IrType,
override val isActual: Boolean,
override var isActual: Boolean,
override var origin: IrDeclarationOrigin,
override val factory: IrFactory = IrFactoryImpl,
) : IrTypeAlias() {
@@ -23,9 +23,9 @@ class IrTypeParameterImpl(
override var origin: IrDeclarationOrigin,
override val symbol: IrTypeParameterSymbol,
override var name: Name,
override val index: Int,
override val isReified: Boolean,
override val variance: Variance,
override var index: Int,
override var isReified: Boolean,
override var variance: Variance,
override val factory: IrFactory = IrFactoryImpl,
) : IrTypeParameter() {
init {
@@ -23,12 +23,12 @@ class IrValueParameterImpl(
override var origin: IrDeclarationOrigin,
override val symbol: IrValueParameterSymbol,
override var name: Name,
override val index: Int,
override var index: Int,
override var type: IrType,
override var varargElementType: IrType?,
override val isCrossinline: Boolean,
override val isNoinline: Boolean,
override val isHidden: Boolean,
override var isCrossinline: Boolean,
override var isNoinline: Boolean,
override var isHidden: Boolean,
override val isAssignable: Boolean,
override val factory: IrFactory = IrFactoryImpl,
) : IrValueParameter() {
@@ -35,9 +35,9 @@ class IrVariableImpl(
override val symbol: IrVariableSymbol,
override var name: Name,
override var type: IrType,
override val isVar: Boolean,
override val isConst: Boolean,
override val isLateinit: Boolean
override var isVar: Boolean,
override var isConst: Boolean,
override var isLateinit: Boolean
) : IrVariable() {
private var _parent: IrDeclarationParent? = null
override var parent: IrDeclarationParent
@@ -27,16 +27,16 @@ class IrLazyClass(
@OptIn(ObsoleteDescriptorBasedAPI::class)
override val descriptor: ClassDescriptor,
override var name: Name,
override val kind: ClassKind,
override var kind: ClassKind,
override var visibility: DescriptorVisibility,
override var modality: Modality,
override val isCompanion: Boolean,
override val isInner: Boolean,
override val isData: Boolean,
override val isExternal: Boolean,
override val isValue: Boolean,
override val isExpect: Boolean,
override val isFun: Boolean,
override var isCompanion: Boolean,
override var isInner: Boolean,
override var isData: Boolean,
override var isExternal: Boolean,
override var isValue: Boolean,
override var isExpect: Boolean,
override var isFun: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator
) : IrClass(), IrLazyDeclarationBase, DeserializableClass {
@@ -29,10 +29,10 @@ class IrLazyConstructor(
override val descriptor: ClassConstructorDescriptor,
override var name: Name,
override var visibility: DescriptorVisibility,
override val isInline: Boolean,
override val isExternal: Boolean,
override val isPrimary: Boolean,
override val isExpect: Boolean,
override var isInline: Boolean,
override var isExternal: Boolean,
override var isPrimary: Boolean,
override var isExpect: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
) : IrConstructor(), IrLazyFunctionBase {
@@ -31,9 +31,9 @@ class IrLazyField(
override val descriptor: PropertyDescriptor,
override var name: Name,
override var visibility: DescriptorVisibility,
override val isFinal: Boolean,
override val isExternal: Boolean,
override val isStatic: Boolean,
override var isFinal: Boolean,
override var isExternal: Boolean,
override var isStatic: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
) : IrField(), IrLazyDeclarationBase {
@@ -33,15 +33,15 @@ class IrLazyFunction(
override val descriptor: FunctionDescriptor,
override var name: Name,
override var visibility: DescriptorVisibility,
override val modality: Modality,
override val isInline: Boolean,
override val isExternal: Boolean,
override val isTailrec: Boolean,
override val isSuspend: Boolean,
override val isExpect: Boolean,
override val isFakeOverride: Boolean,
override val isOperator: Boolean,
override val isInfix: Boolean,
override var modality: Modality,
override var isInline: Boolean,
override var isExternal: Boolean,
override var isTailrec: Boolean,
override var isSuspend: Boolean,
override var isExpect: Boolean,
override var isFakeOverride: Boolean,
override var isOperator: Boolean,
override var isInfix: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
) : IrSimpleFunction(), IrLazyFunctionBase {
@@ -129,4 +129,3 @@ class IrLazyFunction(
symbol.bind(this)
}
}
@@ -27,14 +27,14 @@ class IrLazyProperty(
override val descriptor: PropertyDescriptor,
override var name: Name,
override var visibility: DescriptorVisibility,
override val modality: Modality,
override val isVar: Boolean,
override val isConst: Boolean,
override val isLateinit: Boolean,
override val isDelegated: Boolean,
override val isExternal: Boolean,
override val isExpect: Boolean,
override val isFakeOverride: Boolean,
override var modality: Modality,
override var isVar: Boolean,
override var isConst: Boolean,
override var isLateinit: Boolean,
override var isDelegated: Boolean,
override var isExternal: Boolean,
override var isExpect: Boolean,
override var isFakeOverride: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
) : IrProperty(), IrLazyDeclarationBase {
@@ -25,7 +25,7 @@ class IrLazyTypeAlias(
override val descriptor: TypeAliasDescriptor,
override var name: Name,
override var visibility: DescriptorVisibility,
override val isActual: Boolean,
override var isActual: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
) : IrTypeAlias(), IrLazyDeclarationBase {
@@ -24,9 +24,9 @@ class IrLazyTypeParameter(
override val symbol: IrTypeParameterSymbol,
override val descriptor: TypeParameterDescriptor,
override var name: Name,
override val index: Int,
override val isReified: Boolean,
override val variance: Variance,
override var index: Int,
override var isReified: Boolean,
override var variance: Variance,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
) : IrTypeParameter(), IrLazyDeclarationBase {
@@ -27,12 +27,12 @@ class IrLazyValueParameter(
override val symbol: IrValueParameterSymbol,
override val descriptor: ValueParameterDescriptor,
override var name: Name,
override val index: Int,
override var index: Int,
kotlinType: KotlinType,
varargElementKotlinType: KotlinType?,
override val isCrossinline: Boolean,
override val isNoinline: Boolean,
override val isHidden: Boolean,
override var isCrossinline: Boolean,
override var isNoinline: Boolean,
override var isHidden: Boolean,
override val isAssignable: Boolean,
override val stubGenerator: DeclarationStubGenerator,
override val typeTranslator: TypeTranslator,
@@ -30,7 +30,7 @@ class IrBlockImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val origin: IrStatementOrigin? = null,
override var origin: IrStatementOrigin? = null,
) : IrBlock() {
constructor(
startOffset: Int,
@@ -60,8 +60,8 @@ class IrReturnableBlockImpl(
override val endOffset: Int,
override var type: IrType,
override val symbol: IrReturnableBlockSymbol,
override val origin: IrStatementOrigin? = null,
override val inlineFunctionSymbol: IrFunctionSymbol? = null
override var origin: IrStatementOrigin? = null,
override var inlineFunctionSymbol: IrFunctionSymbol? = null
) : IrReturnableBlock() {
@ObsoleteDescriptorBasedAPI
override val descriptor: FunctionDescriptor
@@ -35,7 +35,7 @@ class IrCallImpl(
typeArgumentsCount: Int,
valueArgumentsCount: Int,
override val origin: IrStatementOrigin? = null,
override val superQualifierSymbol: IrClassSymbol? = null
override var superQualifierSymbol: IrClassSymbol? = null
) : IrCall() {
override val typeArgumentsByIndex: Array<IrType?> = arrayOfNulls(typeArgumentsCount)
@@ -25,7 +25,7 @@ class IrCompositeImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val origin: IrStatementOrigin? = null,
override var origin: IrStatementOrigin? = null,
) : IrComposite() {
constructor(
startOffset: Int,
@@ -28,8 +28,8 @@ class IrConstImpl<T>(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val kind: IrConstKind<T>,
override val value: T
override var kind: IrConstKind<T>,
override var value: T
) : IrConst<T>() {
companion object {
fun string(startOffset: Int, endOffset: Int, type: IrType, value: String): IrConstImpl<String> =
@@ -37,7 +37,7 @@ class IrConstantPrimitiveImpl(
class IrConstantObjectImpl constructor(
override val startOffset: Int,
override val endOffset: Int,
override val constructor: IrConstructorSymbol,
override var constructor: IrConstructorSymbol,
initArguments: List<IrConstantValue>,
override val typeArguments: List<IrType>,
override var type: IrType = constructor.owner.constructedClassType,
@@ -21,10 +21,10 @@ class IrConstructorCallImpl(
override var type: IrType,
override val symbol: IrConstructorSymbol,
typeArgumentsCount: Int,
override val constructorTypeArgumentsCount: Int,
override var constructorTypeArgumentsCount: Int,
valueArgumentsCount: Int,
override val origin: IrStatementOrigin? = null,
override val source: SourceElement = SourceElement.NO_SOURCE
override var source: SourceElement = SourceElement.NO_SOURCE
) : IrConstructorCall() {
override val typeArgumentsByIndex: Array<IrType?> = arrayOfNulls(typeArgumentsCount)
@@ -25,7 +25,7 @@ class IrDoWhileLoopImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val origin: IrStatementOrigin?,
override var origin: IrStatementOrigin?,
) : IrDoWhileLoop() {
override lateinit var condition: IrExpression
}
@@ -13,6 +13,6 @@ class IrDynamicMemberExpressionImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val memberName: String,
override var memberName: String,
override var receiver: IrExpression
) : IrDynamicMemberExpression()
@@ -15,7 +15,7 @@ class IrDynamicOperatorExpressionImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val operator: IrDynamicOperator
override var operator: IrDynamicOperator
) : IrDynamicOperatorExpression() {
override lateinit var receiver: IrExpression
@@ -25,7 +25,7 @@ class IrErrorCallExpressionImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val description: String
override var description: String
) : IrErrorCallExpression() {
override var explicitReceiver: IrExpression? = null
override val arguments: MutableList<IrExpression> = SmartList()
@@ -23,5 +23,5 @@ class IrErrorExpressionImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val description: String
override var description: String
) : IrErrorExpression()
@@ -15,5 +15,5 @@ class IrFunctionExpressionImpl(
override val endOffset: Int,
override var type: IrType,
override var function: IrSimpleFunction,
override val origin: IrStatementOrigin
override var origin: IrStatementOrigin
) : IrFunctionExpression()
@@ -30,7 +30,7 @@ class IrFunctionReferenceImpl(
override val symbol: IrFunctionSymbol,
typeArgumentsCount: Int,
valueArgumentsCount: Int,
override val reflectionTarget: IrFunctionSymbol? = symbol,
override var reflectionTarget: IrFunctionSymbol? = symbol,
override val origin: IrStatementOrigin? = null,
) : IrFunctionReference() {
override val typeArgumentsByIndex: Array<IrType?> = arrayOfNulls(typeArgumentsCount)
@@ -28,8 +28,8 @@ class IrGetFieldImpl(
override val endOffset: Int,
override val symbol: IrFieldSymbol,
override var type: IrType,
override val origin: IrStatementOrigin? = null,
override val superQualifierSymbol: IrClassSymbol? = null,
override var origin: IrStatementOrigin? = null,
override var superQualifierSymbol: IrClassSymbol? = null,
) : IrGetField() {
constructor(
startOffset: Int, endOffset: Int,
@@ -15,7 +15,7 @@ class IrGetValueImpl(
override val endOffset: Int,
override var type: IrType,
override val symbol: IrValueSymbol,
override val origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin? = null
) : IrGetValue() {
constructor(
startOffset: Int,
@@ -26,7 +26,7 @@ class IrIfThenElseImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin? = null
) : IrWhen() {
override val branches: MutableList<IrBranch> = SmartList()
}
@@ -23,6 +23,6 @@ import org.jetbrains.kotlin.ir.types.IrType
class IrInstanceInitializerCallImpl(
override val startOffset: Int,
override val endOffset: Int,
override val classSymbol: IrClassSymbol,
override var classSymbol: IrClassSymbol,
override var type: IrType,
) : IrInstanceInitializerCall()
@@ -29,9 +29,9 @@ class IrLocalDelegatedPropertyReferenceImpl(
override val endOffset: Int,
override var type: IrType,
override val symbol: IrLocalDelegatedPropertySymbol,
override val delegate: IrVariableSymbol,
override val getter: IrSimpleFunctionSymbol,
override val setter: IrSimpleFunctionSymbol?,
override var delegate: IrVariableSymbol,
override var getter: IrSimpleFunctionSymbol,
override var setter: IrSimpleFunctionSymbol?,
override val origin: IrStatementOrigin? = null,
) : IrLocalDelegatedPropertyReference() {
override val typeArgumentsByIndex: Array<IrType?> = emptyArray()
@@ -30,9 +30,9 @@ class IrPropertyReferenceImpl(
override var type: IrType,
override val symbol: IrPropertySymbol,
typeArgumentsCount: Int,
override val field: IrFieldSymbol?,
override val getter: IrSimpleFunctionSymbol?,
override val setter: IrSimpleFunctionSymbol?,
override var field: IrFieldSymbol?,
override var getter: IrSimpleFunctionSymbol?,
override var setter: IrSimpleFunctionSymbol?,
override val origin: IrStatementOrigin? = null,
) : IrPropertyReference() {
override val typeArgumentsByIndex: Array<IrType?> = arrayOfNulls(typeArgumentsCount)
@@ -25,6 +25,6 @@ class IrReturnImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val returnTargetSymbol: IrReturnTargetSymbol,
override var returnTargetSymbol: IrReturnTargetSymbol,
override var value: IrExpression
) : IrReturn()
@@ -28,8 +28,8 @@ class IrSetFieldImpl(
override val endOffset: Int,
override val symbol: IrFieldSymbol,
override var type: IrType,
override val origin: IrStatementOrigin? = null,
override val superQualifierSymbol: IrClassSymbol? = null,
override var origin: IrStatementOrigin? = null,
override var superQualifierSymbol: IrClassSymbol? = null,
) : IrSetField() {
constructor(
startOffset: Int, endOffset: Int,
@@ -28,7 +28,7 @@ class IrSetValueImpl(
override var type: IrType,
override val symbol: IrValueSymbol,
override var value: IrExpression,
override val origin: IrStatementOrigin?
override var origin: IrStatementOrigin?
) : IrSetValue() {
init {
if (symbol.isBound) {
@@ -22,7 +22,7 @@ import org.jetbrains.kotlin.ir.expressions.IrSyntheticBodyKind
class IrSyntheticBodyImpl(
override val startOffset: Int,
override val endOffset: Int,
override val kind: IrSyntheticBodyKind
override var kind: IrSyntheticBodyKind
) : IrSyntheticBody() {
override fun toString(): String =
"IrSyntheticBodyImpl($kind)"
@@ -25,7 +25,7 @@ class IrTypeOperatorCallImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val operator: IrTypeOperator,
override var operator: IrTypeOperator,
override var typeOperand: IrType,
override var argument: IrExpression,
) : IrTypeOperatorCall()
@@ -23,7 +23,7 @@ class IrWhenImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val origin: IrStatementOrigin? = null
override var origin: IrStatementOrigin? = null
) : IrWhen() {
constructor(
startOffset: Int,
@@ -25,7 +25,7 @@ class IrWhileLoopImpl(
override val startOffset: Int,
override val endOffset: Int,
override var type: IrType,
override val origin: IrStatementOrigin?,
override var origin: IrStatementOrigin?,
) : IrWhileLoop() {
override lateinit var condition: IrExpression
}
@@ -37,10 +37,12 @@ object IrErrorClassImpl : IrClassImpl(
get() = TODO("Not yet implemented")
override val symbol: IrFileSymbol
get() = TODO("Not yet implemented")
override val module: IrModuleFragment
override var module: IrModuleFragment
get() = TODO("Not yet implemented")
override val fileEntry: IrFileEntry
set(_) = TODO("Not yet implemented")
override var fileEntry: IrFileEntry
get() = TODO("Not yet implemented")
set(_) = TODO("Not yet implemented")
override var metadata: MetadataSource?
get() = TODO("Not yet implemented")
set(_) {}
@@ -48,8 +50,9 @@ object IrErrorClassImpl : IrClassImpl(
@ObsoleteDescriptorBasedAPI
override val packageFragmentDescriptor: PackageFragmentDescriptor
get() = TODO("Not yet implemented")
override val fqName: FqName
override var fqName: FqName
get() = FqName.ROOT
set(_) = TODO("Not yet implemented")
}
set(_) = TODO()
}
}
@@ -30,19 +30,19 @@ import org.jetbrains.kotlin.types.Variance
// 2) parents
// 3) fields
object IrTree : AbstractTreeBuilder() {
private fun symbol(type: TypeRef) = field("symbol", type)
private fun symbol(type: TypeRef) = field("symbol", type, mutable = false)
private fun descriptor(typeName: String) =
field("descriptor", ClassRef<TypeParameterRef>(TypeKind.Interface, "org.jetbrains.kotlin.descriptors", typeName))
field("descriptor", ClassRef<TypeParameterRef>(TypeKind.Interface, "org.jetbrains.kotlin.descriptors", typeName), mutable = false)
private val factory: SimpleFieldConfig = field("factory", type(Packages.declarations, "IrFactory"))
private val factory: SimpleFieldConfig = field("factory", type(Packages.declarations, "IrFactory"), mutable = false)
override val rootElement: ElementConfig by element(Other, name = "element") {
accept = true
transform = true
transformByChildren = true
+field("startOffset", int)
+field("endOffset", int)
+field("startOffset", int, mutable = false)
+field("endOffset", int, mutable = false)
}
val statement: ElementConfig by element(Other)
@@ -52,8 +52,8 @@ object IrTree : AbstractTreeBuilder() {
parent(mutableAnnotationContainerType)
+descriptor("DeclarationDescriptor")
+field("origin", type(Packages.declarations, "IrDeclarationOrigin"), mutable = true)
+field("parent", declarationParent, mutable = true)
+field("origin", type(Packages.declarations, "IrDeclarationOrigin"))
+field("parent", declarationParent)
+factory
}
val declarationBase: ElementConfig by element(Declaration) {
@@ -69,12 +69,12 @@ object IrTree : AbstractTreeBuilder() {
val declarationWithVisibility: ElementConfig by element(Declaration) {
parent(declaration)
+field("visibility", type(Packages.descriptors, "DescriptorVisibility"), mutable = true)
+field("visibility", type(Packages.descriptors, "DescriptorVisibility"))
}
val declarationWithName: ElementConfig by element(Declaration) {
parent(declaration)
+field("name", type<Name>(), mutable = true)
+field("name", type<Name>())
}
val possiblyExternalDeclaration: ElementConfig by element(Declaration) {
parent(declarationWithName)
@@ -85,7 +85,7 @@ object IrTree : AbstractTreeBuilder() {
+symbol(symbolType)
}
val metadataSourceOwner: ElementConfig by element(Declaration) {
+field("metadata", type(Packages.declarations, "MetadataSource"), nullable = true, mutable = true)
+field("metadata", type(Packages.declarations, "MetadataSource"), nullable = true)
}
val overridableMember: ElementConfig by element(Declaration) {
parent(declaration)
@@ -100,14 +100,14 @@ object IrTree : AbstractTreeBuilder() {
parent(overridableMember)
+field("symbol", s)
+field("symbol", s, mutable = false)
+field("isFakeOverride", boolean)
+listField("overriddenSymbols", s, mutability = Var)
}
val memberWithContainerSource: ElementConfig by element(Declaration) {
parent(declarationWithName)
+field("containerSource", type<DeserializedContainerSource>(), nullable = true)
+field("containerSource", type<DeserializedContainerSource>(), nullable = true, mutable = false)
}
val valueDeclaration: ElementConfig by element(Declaration) {
parent(declarationWithName)
@@ -115,8 +115,8 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("ValueDescriptor")
+symbol(valueSymbolType)
+field("type", irTypeType, mutable = true)
+field("isAssignable", boolean)
+field("type", irTypeType)
+field("isAssignable", boolean, mutable = false)
}
val valueParameter: ElementConfig by element(Declaration) {
transform = true
@@ -128,7 +128,7 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("ParameterDescriptor")
+symbol(valueParameterSymbolType)
+field("index", int)
+field("varargElementType", irTypeType, nullable = true, mutable = true)
+field("varargElementType", irTypeType, nullable = true)
+field("isCrossinline", boolean)
+field("isNoinline", boolean)
// if true parameter is not included into IdSignature.
@@ -136,7 +136,7 @@ object IrTree : AbstractTreeBuilder() {
// NOTE: it is introduced to fix KT-40980 because more clear solution was not possible to implement.
// Once we are able to load any top-level declaration from klib this hack should be deprecated and removed.
+field("isHidden", boolean)
+field("defaultValue", expressionBody, nullable = true, mutable = true, isChild = true)
+field("defaultValue", expressionBody, nullable = true, isChild = true)
}
val `class`: ElementConfig by element(Declaration) {
visitorParent = declarationBase
@@ -152,26 +152,25 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("ClassDescriptor")
+symbol(classSymbolType)
+field("kind", type<ClassKind>())
+field("modality", type<Modality>(), mutable = true)
+field("modality", type<Modality>())
+field("isCompanion", boolean)
+field("isInner", boolean)
+field("isData", boolean)
+field("isValue", boolean)
+field("isExpect", boolean)
+field("isFun", boolean)
+field("source", type<SourceElement>())
+field("source", type<SourceElement>(), mutable = false)
+listField("superTypes", irTypeType, mutability = Var)
+field("thisReceiver", valueParameter, nullable = true, mutable = true, isChild = true)
+field("thisReceiver", valueParameter, nullable = true, isChild = true)
+field(
"valueClassRepresentation",
type<ValueClassRepresentation<*>>().withArgs(type(Packages.types, "IrSimpleType")),
nullable = true,
mutable = true
)
+listField("sealedSubclasses", classSymbolType, mutability = Var)
}
val attributeContainer: ElementConfig by element(Declaration) {
+field("attributeOwnerId", attributeContainer, mutable = true)
+field("attributeOwnerId", attributeContainer)
}
val anonymousInitializer: ElementConfig by element(Declaration) {
visitorParent = declarationBase
@@ -181,7 +180,7 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("ClassDescriptor") // TODO special descriptor for anonymous initializer blocks
+symbol(anonymousInitializerSymbolType)
+field("isStatic", boolean)
+field("body", blockBody, mutable = true, isChild = true)
+field("body", blockBody, isChild = true)
}
val declarationContainer: ElementConfig by element(Declaration) {
ownsChildren = false
@@ -236,13 +235,13 @@ object IrTree : AbstractTreeBuilder() {
// NB: there's an inline constructor for Array and each primitive array class.
+field("isInline", boolean)
+field("isExpect", boolean)
+field("returnType", irTypeType, mutable = true)
+field("dispatchReceiverParameter", valueParameter, mutable = true, nullable = true, isChild = true)
+field("extensionReceiverParameter", valueParameter, mutable = true, nullable = true, isChild = true)
+field("returnType", irTypeType)
+field("dispatchReceiverParameter", valueParameter, nullable = true, isChild = true)
+field("extensionReceiverParameter", valueParameter, nullable = true, isChild = true)
+listField("valueParameters", valueParameter, mutability = Var, isChild = true)
// The first `contextReceiverParametersCount` value parameters are context receivers.
+field("contextReceiverParametersCount", int, mutable = true)
+field("body", body, mutable = true, nullable = true, isChild = true)
+field("contextReceiverParametersCount", int)
+field("body", body, nullable = true, isChild = true)
}
val constructor: ElementConfig by element(Declaration) {
visitorParent = function
@@ -261,15 +260,15 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("ClassDescriptor")
+symbol(enumEntrySymbolType)
+field("initializerExpression", expressionBody, mutable = true, nullable = true, isChild = true)
+field("correspondingClass", `class`, mutable = true, nullable = true, isChild = true)
+field("initializerExpression", expressionBody, nullable = true, isChild = true)
+field("correspondingClass", `class`, nullable = true, isChild = true)
}
val errorDeclaration: ElementConfig by element(Declaration) {
visitorParent = declarationBase
parent(declarationBase)
+field("symbol", symbolType) {
+field("symbol", symbolType, mutable = false) {
baseGetter = code("error(\"Should never be called\")")
}
}
@@ -279,8 +278,8 @@ object IrTree : AbstractTreeBuilder() {
parent(declaration)
+symbol(simpleFunctionSymbolType)
+field("modality", type<Modality>(), mutable = true)
+field("isBound", boolean)
+field("modality", type<Modality>())
+field("isBound", boolean, mutable = false)
generationCallback = {
addFunction(
FunSpec.builder("acquireSymbol")
@@ -297,10 +296,10 @@ object IrTree : AbstractTreeBuilder() {
parent(declaration)
+symbol(propertySymbolType)
+field("modality", type<Modality>(), mutable = true)
+field("getter", simpleFunction, mutable = true, nullable = true)
+field("setter", simpleFunction, mutable = true, nullable = true)
+field("isBound", boolean)
+field("modality", type<Modality>())
+field("getter", simpleFunction, nullable = true)
+field("setter", simpleFunction, nullable = true)
+field("isBound", boolean, mutable = false)
generationCallback = {
addFunction(
FunSpec.builder("acquireSymbol")
@@ -322,11 +321,11 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("PropertyDescriptor")
+symbol(fieldSymbolType)
+field("type", irTypeType, mutable = true)
+field("type", irTypeType)
+field("isFinal", boolean)
+field("isStatic", boolean)
+field("initializer", expressionBody, mutable = true, nullable = true, isChild = true)
+field("correspondingPropertySymbol", propertySymbolType, mutable = true, nullable = true)
+field("initializer", expressionBody, nullable = true, isChild = true)
+field("correspondingPropertySymbol", propertySymbolType, nullable = true)
}
val localDelegatedProperty: ElementConfig by element(Declaration) {
visitorParent = declarationBase
@@ -338,11 +337,11 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("VariableDescriptorWithAccessors")
+symbol(localDelegatedPropertySymbolType)
+field("type", irTypeType, mutable = true)
+field("type", irTypeType)
+field("isVar", boolean)
+field("delegate", variable, mutable = true, isChild = true)
+field("getter", simpleFunction, mutable = true, isChild = true)
+field("setter", simpleFunction, mutable = true, nullable = true, isChild = true)
+field("delegate", variable, isChild = true)
+field("getter", simpleFunction, isChild = true)
+field("setter", simpleFunction, nullable = true, isChild = true)
}
val moduleFragment: ElementConfig by element(Declaration) {
visitorParent = rootElement
@@ -350,14 +349,14 @@ object IrTree : AbstractTreeBuilder() {
transformByChildren = true
+descriptor("ModuleDescriptor")
+field("name", type<Name>())
+field("irBuiltins", type(Packages.tree, "IrBuiltIns"))
+field("name", type<Name>(), mutable = false)
+field("irBuiltins", type(Packages.tree, "IrBuiltIns"), mutable = false)
+listField("files", file, mutability = List, isChild = true)
val undefinedOffset = MemberName(Packages.tree, "UNDEFINED_OFFSET")
+field("startOffset", int) {
+field("startOffset", int, mutable = false) {
baseGetter = code("%M", undefinedOffset)
}
+field("endOffset", int) {
+field("endOffset", int, mutable = false) {
baseGetter = code("%M", undefinedOffset)
}
}
@@ -379,9 +378,9 @@ object IrTree : AbstractTreeBuilder() {
+field("isDelegated", boolean)
+field("isExpect", boolean)
+field("isFakeOverride", boolean)
+field("backingField", field, mutable = true, nullable = true, isChild = true)
+field("getter", simpleFunction, mutable = true, nullable = true, isChild = true)
+field("setter", simpleFunction, mutable = true, nullable = true, isChild = true)
+field("backingField", field, nullable = true, isChild = true)
+field("getter", simpleFunction, nullable = true, isChild = true)
+field("setter", simpleFunction, nullable = true, isChild = true)
}
//TODO: make IrScript as IrPackageFragment, because script is used as a file, not as a class
@@ -398,17 +397,17 @@ object IrTree : AbstractTreeBuilder() {
+symbol(scriptSymbolType)
// NOTE: is the result of the FE conversion, because there script interpreted as a class and has receiver
// TODO: consider removing from here and handle appropriately in the lowering
+field("thisReceiver", valueParameter, mutable = true, isChild = true, nullable = true) // K1
+field("baseClass", irTypeType, mutable = true, nullable = true) // K1
+field("thisReceiver", valueParameter, isChild = true, nullable = true) // K1
+field("baseClass", irTypeType, nullable = true) // K1
+listField("explicitCallParameters", variable, mutability = Var, isChild = true)
+listField("implicitReceiversParameters", valueParameter, mutability = Var, isChild = true)
+listField("providedProperties", propertySymbolType, mutability = Var)
+listField("providedPropertiesParameters", valueParameter, mutability = Var, isChild = true)
+field("resultProperty", propertySymbolType, mutable = true, nullable = true)
+field("earlierScriptsParameter", valueParameter, mutable = true, nullable = true, isChild = true)
+field("resultProperty", propertySymbolType, nullable = true)
+field("earlierScriptsParameter", valueParameter, nullable = true, isChild = true)
+listField("earlierScripts", scriptSymbolType, mutability = Var, nullable = true)
+field("targetClass", classSymbolType, mutable = true, nullable = true)
+field("constructor", constructor, mutable = true, nullable = true) // K1
+field("targetClass", classSymbolType, nullable = true)
+field("constructor", constructor, nullable = true) // K1
}
val simpleFunction: ElementConfig by element(Declaration) {
visitorParent = function
@@ -423,7 +422,7 @@ object IrTree : AbstractTreeBuilder() {
+field("isFakeOverride", boolean)
+field("isOperator", boolean)
+field("isInfix", boolean)
+field("correspondingPropertySymbol", propertySymbolType, mutable = true, nullable = true)
+field("correspondingPropertySymbol", propertySymbolType, nullable = true)
}
val typeAlias: ElementConfig by element(Declaration) {
visitorParent = declarationBase
@@ -436,7 +435,7 @@ object IrTree : AbstractTreeBuilder() {
+descriptor("TypeAliasDescriptor")
+symbol(typeAliasSymbolType)
+field("isActual", boolean)
+field("expandedType", irTypeType, mutable = true)
+field("expandedType", irTypeType)
}
val variable: ElementConfig by element(Declaration) {
visitorParent = declarationBase
@@ -449,7 +448,7 @@ object IrTree : AbstractTreeBuilder() {
+field("isVar", boolean)
+field("isConst", boolean)
+field("isLateinit", boolean)
+field("initializer", expression, nullable = true, mutable = true, isChild = true)
+field("initializer", expression, nullable = true, isChild = true)
}
val packageFragment: ElementConfig by element(Declaration) {
visitorParent = rootElement
@@ -459,7 +458,7 @@ object IrTree : AbstractTreeBuilder() {
parent(symbolOwner)
+symbol(packageFragmentSymbolType)
+field("packageFragmentDescriptor", type(Packages.descriptors, "PackageFragmentDescriptor"))
+field("packageFragmentDescriptor", type(Packages.descriptors, "PackageFragmentDescriptor"), mutable = false)
+field("fqName", type<FqName>())
}
val externalPackageFragment: ElementConfig by element(Declaration) {
@@ -469,7 +468,7 @@ object IrTree : AbstractTreeBuilder() {
parent(packageFragment)
+symbol(externalPackageFragmentSymbolType)
+field("containerSource", type<DeserializedContainerSource>(), nullable = true)
+field("containerSource", type<DeserializedContainerSource>(), nullable = true, mutable = false)
}
val file: ElementConfig by element(Declaration) {
transform = true
@@ -494,10 +493,10 @@ object IrTree : AbstractTreeBuilder() {
parent(varargElement)
parent(attributeContainer)
+field("attributeOwnerId", attributeContainer, mutable = true) {
+field("attributeOwnerId", attributeContainer) {
baseDefaultValue = code("this")
}
+field("type", irTypeType, mutable = true)
+field("type", irTypeType)
}
val statementContainer: ElementConfig by element(Expression) {
ownsChildren = false
@@ -519,7 +518,7 @@ object IrTree : AbstractTreeBuilder() {
parent(body)
+factory
+field("expression", expression, mutable = true, isChild = true)
+field("expression", expression, isChild = true)
}
val blockBody: ElementConfig by element(Expression) {
visitorParent = body
@@ -547,10 +546,10 @@ object IrTree : AbstractTreeBuilder() {
parent(declarationReference)
+field("dispatchReceiver", expression, nullable = true, mutable = true, isChild = true) {
+field("dispatchReceiver", expression, nullable = true, isChild = true) {
baseDefaultValue = code("this")
}
+field("extensionReceiver", expression, nullable = true, mutable = true, isChild = true) {
+field("extensionReceiver", expression, nullable = true, isChild = true) {
baseDefaultValue = code("this")
}
+symbol(s)
@@ -565,7 +564,7 @@ object IrTree : AbstractTreeBuilder() {
parent(memberAccessExpression.withArgs("S" to functionSymbolType))
+field("contextReceiversCount", int, mutable = true)
+field("contextReceiversCount", int)
}
val constructorCall: ElementConfig by element(Expression) {
visitorParent = functionAccessExpression
@@ -658,8 +657,8 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("loop", loop, mutable = true)
+field("label", string, nullable = true, mutable = true) {
+field("loop", loop)
+field("label", string, nullable = true) {
baseDefaultValue = code("null")
}
}
@@ -720,7 +719,7 @@ object IrTree : AbstractTreeBuilder() {
parent(declarationReference)
+symbol(classifierSymbolType)
+field("classType", irTypeType, mutable = true)
+field("classType", irTypeType)
}
val const: ElementConfig by element(Expression) {
visitorParent = expression
@@ -758,7 +757,7 @@ object IrTree : AbstractTreeBuilder() {
parent(constantValue)
+field("value", const.withArgs("T" to TypeRef.Star), mutable = true, isChild = true)
+field("value", const.withArgs("T" to TypeRef.Star), isChild = true)
}
val constantObject: ElementConfig by element(Expression) {
visitorParent = constantValue
@@ -794,7 +793,7 @@ object IrTree : AbstractTreeBuilder() {
parent(dynamicExpression)
+field("operator", type(Packages.exprs, "IrDynamicOperator"))
+field("receiver", expression, mutable = true, isChild = true)
+field("receiver", expression, isChild = true)
+listField("arguments", expression, mutability = List, isChild = true)
}
val dynamicMemberExpression: ElementConfig by element(Expression) {
@@ -803,7 +802,7 @@ object IrTree : AbstractTreeBuilder() {
parent(dynamicExpression)
+field("memberName", string)
+field("receiver", expression, mutable = true, isChild = true)
+field("receiver", expression, isChild = true)
}
val enumConstructorCall: ElementConfig by element(Expression) {
visitorParent = functionAccessExpression
@@ -825,7 +824,7 @@ object IrTree : AbstractTreeBuilder() {
parent(errorExpression)
+field("explicitReceiver", expression, nullable = true, mutable = true, isChild = true)
+field("explicitReceiver", expression, nullable = true, isChild = true)
+listField("arguments", expression, mutability = List, isChild = true)
}
val fieldAccessExpression: ElementConfig by element(Expression) {
@@ -837,7 +836,7 @@ object IrTree : AbstractTreeBuilder() {
+symbol(fieldSymbolType)
+field("superQualifierSymbol", classSymbolType, nullable = true)
+field("receiver", expression, nullable = true, mutable = true, isChild = true) {
+field("receiver", expression, nullable = true, isChild = true) {
baseDefaultValue = code("null")
}
+field("origin", statementOriginType, nullable = true)
@@ -852,7 +851,7 @@ object IrTree : AbstractTreeBuilder() {
parent(fieldAccessExpression)
+field("value", expression, mutable = true, isChild = true)
+field("value", expression, isChild = true)
}
val functionExpression: ElementConfig by element(Expression) {
visitorParent = expression
@@ -861,14 +860,14 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("origin", statementOriginType)
+field("function", simpleFunction, mutable = true, isChild = true)
+field("function", simpleFunction, isChild = true)
}
val getClass: ElementConfig by element(Expression) {
visitorParent = expression
parent(expression)
+field("argument", expression, mutable = true, isChild = true)
+field("argument", expression, isChild = true)
}
val instanceInitializerCall: ElementConfig by element(Expression) {
visitorParent = expression
@@ -885,11 +884,11 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("origin", statementOriginType, nullable = true)
+field("body", expression, nullable = true, mutable = true, isChild = true) {
+field("body", expression, nullable = true, isChild = true) {
baseDefaultValue = code("null")
}
+field("condition", expression, mutable = true, isChild = true)
+field("label", string, nullable = true, mutable = true) {
+field("condition", expression, isChild = true)
+field("label", string, nullable = true) {
baseDefaultValue = code("null")
}
}
@@ -911,7 +910,7 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("value", expression, mutable = true, isChild = true)
+field("value", expression, isChild = true)
+field("returnTargetSymbol", returnTargetSymbolType)
}
val stringConcatenation: ElementConfig by element(Expression) {
@@ -926,24 +925,24 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("suspensionPointIdParameter", variable, mutable = true, isChild = true)
+field("result", expression, mutable = true, isChild = true)
+field("resumeResult", expression, mutable = true, isChild = true)
+field("suspensionPointIdParameter", variable, isChild = true)
+field("result", expression, isChild = true)
+field("resumeResult", expression, isChild = true)
}
val suspendableExpression: ElementConfig by element(Expression) {
visitorParent = expression
parent(expression)
+field("suspensionPointId", expression, mutable = true, isChild = true)
+field("result", expression, mutable = true, isChild = true)
+field("suspensionPointId", expression, isChild = true)
+field("result", expression, isChild = true)
}
val `throw`: ElementConfig by element(Expression) {
visitorParent = expression
parent(expression)
+field("value", expression, mutable = true, isChild = true)
+field("value", expression, isChild = true)
}
val `try`: ElementConfig by element(Expression) {
visitorParent = expression
@@ -951,9 +950,9 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("tryResult", expression, mutable = true, isChild = true)
+field("tryResult", expression, isChild = true)
+listField("catches", catch, mutability = List, isChild = true)
+field("finallyExpression", expression, nullable = true, mutable = true, isChild = true)
+field("finallyExpression", expression, nullable = true, isChild = true)
}
val catch: ElementConfig by element(Expression) {
visitorParent = rootElement
@@ -961,8 +960,8 @@ object IrTree : AbstractTreeBuilder() {
transform = true
transformByChildren = true
+field("catchParameter", variable, mutable = true, isChild = true)
+field("result", expression, mutable = true, isChild = true)
+field("catchParameter", variable, isChild = true)
+field("result", expression, isChild = true)
}
val typeOperatorCall: ElementConfig by element(Expression) {
visitorParent = expression
@@ -971,8 +970,8 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("operator", type(Packages.exprs, "IrTypeOperator"))
+field("argument", expression, mutable = true, isChild = true)
+field("typeOperand", irTypeType, mutable = true)
+field("argument", expression, isChild = true)
+field("typeOperand", irTypeType)
}
val valueAccessExpression: ElementConfig by element(Expression) {
visitorParent = declarationReference
@@ -994,7 +993,7 @@ object IrTree : AbstractTreeBuilder() {
parent(valueAccessExpression)
+symbol(valueSymbolType)
+field("value", expression, mutable = true, isChild = true)
+field("value", expression, isChild = true)
}
val varargElement: ElementConfig by element(Expression)
val vararg: ElementConfig by element(Expression) {
@@ -1002,7 +1001,7 @@ object IrTree : AbstractTreeBuilder() {
parent(expression)
+field("varargElementType", irTypeType, mutable = true)
+field("varargElementType", irTypeType)
+listField("elements", varargElement, mutability = List, isChild = true)
}
val spreadElement: ElementConfig by element(Expression) {
@@ -1013,7 +1012,7 @@ object IrTree : AbstractTreeBuilder() {
parent(varargElement)
+field("expression", expression, mutable = true, isChild = true)
+field("expression", expression, isChild = true)
}
val `when`: ElementConfig by element(Expression) {
visitorParent = expression
@@ -1030,8 +1029,8 @@ object IrTree : AbstractTreeBuilder() {
transform = true
transformByChildren = true
+field("condition", expression, mutable = true, isChild = true)
+field("result", expression, mutable = true, isChild = true)
+field("condition", expression, isChild = true)
+field("result", expression, isChild = true)
}
val elseBranch: ElementConfig by element(Expression) {
visitorParent = branch
@@ -38,7 +38,7 @@ abstract class AbstractTreeBuilder {
name: String,
type: TypeRef?,
nullable: Boolean = false,
mutable: Boolean = false,
mutable: Boolean = true,
isChild: Boolean = false,
initializer: SimpleFieldConfig.() -> Unit = {}
): SimpleFieldConfig {