[tree generator] Remove AbstractField.defaultValueInBase

It is now unneeded, and future needs should be possible to
be resolved otherwise.
Removing it will simplify further changes to tree generator,
especially for IR.
This commit is contained in:
Wojciech Litewka
2024-03-12 13:43:42 +01:00
committed by Space Team
parent 6b9a671476
commit c1266daf73
5 changed files with 9 additions and 12 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -52,7 +52,7 @@ abstract class AbstractElementPrinter<Element : AbstractElement<Element, Field,
withIndent {
for (field in filterFields(element)) {
if (field.isParameter) continue
if (!field.withGetter && field.defaultValueInImplementation == null && field.defaultValueInBase == null && field.isFinal && field.fromParent) {
if (!field.withGetter && field.defaultValueInImplementation == null && field.isFinal && field.fromParent) {
continue
}
if (separateFieldsWithBlankLine) println()
@@ -60,7 +60,7 @@ abstract class AbstractElementPrinter<Element : AbstractElement<Element, Field,
field,
inImplementation = false,
override = field.fromParent,
modality = Modality.ABSTRACT.takeIf { !field.isFinal && !kind.isInterface && field.defaultValueInBase == null },
modality = Modality.ABSTRACT.takeIf { !field.isFinal && !kind.isInterface },
)
}
printAdditionalMethods(element)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -50,7 +50,6 @@ abstract class AbstractField<Field : AbstractField<Field>> {
open val containsElement: Boolean
get() = typeRef is ElementOrRef<*> || this is ListField && baseType is ElementOrRef<*>
open val defaultValueInBase: String? get() = null
open val defaultValueInImplementation: String? get() = null
/**
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -42,7 +42,7 @@ abstract class AbstractFieldPrinter<Field : AbstractField<*>>(
modality: Modality? = null,
) {
printer.run {
val defaultValue = if (inImplementation) field.defaultValueInImplementation else field.defaultValueInBase
val defaultValue = if (inImplementation) field.defaultValueInImplementation else null
printPropertyDeclaration(
name = field.name,
type = actualTypeOfField(field),
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -73,11 +73,11 @@ abstract class AbstractImplementation<Implementation, Element, Field>(
}
private fun withDefault(field: Field) =
!field.isFinal && (field.defaultValueInImplementation != null || field.defaultValueInBase != null || field.isLateinit)
!field.isFinal && (field.defaultValueInImplementation != null || field.isLateinit)
val fieldsInConstructor by lazy { allFields.filterNot(::withDefault) }
val fieldsInBody by lazy { allFields.filter(::withDefault).filter { it.defaultValueInBase == null } }
val fieldsInBody by lazy { allFields.filter(::withDefault) }
var requiresOptIn = false