[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
@@ -61,8 +61,7 @@ abstract class AbstractSwiftIrTreeBuilder {
|
||||
isChild: Boolean = true,
|
||||
initializer: SimpleField.() -> Unit = {}
|
||||
): SimpleField {
|
||||
return SimpleField(name, type.copy(nullable), mutable).apply {
|
||||
this.isChild = isChild
|
||||
return SimpleField(name, type.copy(nullable), mutable, isChild).apply {
|
||||
initializer()
|
||||
}
|
||||
}
|
||||
@@ -77,8 +76,8 @@ abstract class AbstractSwiftIrTreeBuilder {
|
||||
name = name,
|
||||
baseType = baseType,
|
||||
isMutable = false,
|
||||
isChild = isChild,
|
||||
).apply {
|
||||
this.isChild = isChild
|
||||
initializer()
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -49,17 +49,19 @@ class SimpleField(
|
||||
name: String,
|
||||
override val typeRef: TypeRefWithNullability,
|
||||
isMutable: Boolean,
|
||||
override val isChild: Boolean,
|
||||
) : Field(name, isMutable) {
|
||||
|
||||
override fun internalCopy() = SimpleField(name, typeRef, isMutable)
|
||||
override fun internalCopy() = SimpleField(name, typeRef, isMutable, isChild)
|
||||
|
||||
override fun replaceType(newType: TypeRefWithNullability) = SimpleField(name, newType, isMutable).also(::updateFieldsInCopy)
|
||||
override fun replaceType(newType: TypeRefWithNullability) = SimpleField(name, newType, isMutable, isChild).also(::updateFieldsInCopy)
|
||||
}
|
||||
|
||||
class ListField(
|
||||
name: String,
|
||||
override val baseType: TypeRef,
|
||||
isMutable: Boolean,
|
||||
override val isChild: Boolean,
|
||||
) : Field(name, isMutable), ListField {
|
||||
|
||||
override val typeRef: ClassRef<PositionTypeParameterRef>
|
||||
@@ -68,7 +70,7 @@ class ListField(
|
||||
override val listType: ClassRef<PositionTypeParameterRef>
|
||||
get() = StandardTypes.list
|
||||
|
||||
override fun internalCopy() = ListField(name, baseType, isMutable)
|
||||
override fun internalCopy() = ListField(name, baseType, isMutable, isChild)
|
||||
|
||||
override fun replaceType(newType: TypeRefWithNullability) = internalCopy().also(::updateFieldsInCopy)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user