[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:
Wojciech Litewka
2024-02-14 16:11:24 +01:00
committed by Space Team
parent 6d5b07ebe9
commit e737320d01
10 changed files with 41 additions and 53 deletions
@@ -64,7 +64,7 @@ abstract class AbstractField<Field : AbstractField<Field>> {
*
* Only has effect if [containsElement] is `true`.
*/
var isChild: Boolean = true
abstract val isChild: Boolean
open val overriddenTypes: MutableSet<TypeRefWithNullability> = mutableSetOf()
@@ -106,7 +106,6 @@ abstract class AbstractField<Field : AbstractField<Field>> {
copy.visibility = visibility
copy.fromParent = fromParent
copy.useInBaseTransformerDetection = useInBaseTransformerDetection
copy.isChild = isChild
copy.overriddenTypes += overriddenTypes
}
}
@@ -368,19 +368,10 @@ abstract class AbstractImplementationConfigurator<Implementation, Element, Imple
withGetter = true
}
/**
* Whether this field semantically represents a reference to a child node of the tree.
*
* This has the effect of including or excluding this field from visiting it by visitors in the generated
* `acceptChildren` and `transformChildren` methods (child fields are always visited in those methods)
*/
var isChild: Boolean = true
fun applyConfiguration() {
field.withGetter = withGetter
field.customSetter = customSetter
isMutable?.let { field.isMutable = it }
field.isChild = isChild
when {
value != null -> field.defaultValueInImplementation = value