[FIR generator] Specify Field.isChild in base tree configuration
instead of inside implementation configuration. Whether a field is a child element is a core concept of the tree, not a matter of particular implementation class. It is especially visible in IR tree, where the base classes implement the acceptChildren method. It will also be more relevant in the future. This also aligns the config style between IR and FIR tree generators. ^KT-65773 In Progress
This commit is contained in:
committed by
Space Team
parent
6d5b07ebe9
commit
e737320d01
+2
-3
@@ -78,8 +78,7 @@ abstract class AbstractTreeBuilder {
|
||||
isChild: Boolean = true,
|
||||
initializer: SingleField.() -> Unit = {}
|
||||
): SingleField {
|
||||
return SingleField(name, type.copy(nullable), mutable).apply {
|
||||
this.isChild = isChild
|
||||
return SingleField(name, type.copy(nullable), mutable, isChild).apply {
|
||||
initializer()
|
||||
}
|
||||
}
|
||||
@@ -103,8 +102,8 @@ abstract class AbstractTreeBuilder {
|
||||
listType = listType,
|
||||
isNullable = nullable,
|
||||
mutable = mutability == ListField.Mutability.Var,
|
||||
isChild = isChild,
|
||||
).apply(initializer).apply {
|
||||
this.isChild = isChild
|
||||
initializer()
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -73,12 +73,13 @@ class SingleField(
|
||||
name: String,
|
||||
override var typeRef: TypeRefWithNullability,
|
||||
mutable: Boolean,
|
||||
override val isChild: Boolean,
|
||||
) : Field(name, mutable) {
|
||||
|
||||
override fun replaceType(newType: TypeRefWithNullability) =
|
||||
SingleField(name, newType, isMutable).also(::updateFieldsInCopy)
|
||||
SingleField(name, newType, isMutable, isChild).also(::updateFieldsInCopy)
|
||||
|
||||
override fun internalCopy() = SingleField(name, typeRef, isMutable)
|
||||
override fun internalCopy() = SingleField(name, typeRef, isMutable, isChild)
|
||||
}
|
||||
|
||||
class ListField(
|
||||
@@ -87,6 +88,7 @@ class ListField(
|
||||
private val isNullable: Boolean,
|
||||
override val listType: ClassRef<PositionTypeParameterRef>,
|
||||
mutable: Boolean,
|
||||
override val isChild: Boolean,
|
||||
) : Field(name, mutable), AbstractListField {
|
||||
|
||||
override val typeRef: ClassRef<PositionTypeParameterRef>
|
||||
@@ -94,7 +96,7 @@ class ListField(
|
||||
|
||||
override fun replaceType(newType: TypeRefWithNullability) = copy()
|
||||
|
||||
override fun internalCopy() = ListField(name, baseType, isNullable, listType, isMutable)
|
||||
override fun internalCopy() = ListField(name, baseType, isNullable, listType, isMutable, isChild)
|
||||
|
||||
enum class Mutability {
|
||||
Var,
|
||||
|
||||
Reference in New Issue
Block a user