[FIR/IR generator] Make AbstractField generic over itself
This will make some code more type-safe.
This commit is contained in:
committed by
Space Team
parent
c6eb7d6c21
commit
38ee477ab4
+1
-1
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.generators.tree.*
|
||||
|
||||
private const val DEFAULT_BUILDER_PACKAGE = "org.jetbrains.kotlin.fir.tree.builder"
|
||||
|
||||
sealed class Builder : FieldContainer, TypeRef, Importable {
|
||||
sealed class Builder : FieldContainer<FieldWithDefault>, TypeRef, Importable {
|
||||
val parents: MutableList<IntermediateBuilder> = mutableListOf()
|
||||
val usedTypes: MutableList<Importable> = mutableListOf()
|
||||
abstract override val allFields: List<FieldWithDefault>
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.tree.generator.model
|
||||
|
||||
import org.jetbrains.kotlin.generators.tree.*
|
||||
|
||||
sealed class Field : AbstractField() {
|
||||
sealed class Field : AbstractField<Field>() {
|
||||
open var withReplace: Boolean = false
|
||||
|
||||
open var needsSeparateTransform: Boolean = false
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.fir.tree.generator.model
|
||||
|
||||
import org.jetbrains.kotlin.generators.tree.*
|
||||
|
||||
class Implementation(val element: Element, val name: String?) : FieldContainer, ImplementationKindOwner {
|
||||
class Implementation(val element: Element, val name: String?) : FieldContainer<FieldWithDefault>, ImplementationKindOwner {
|
||||
override val allParents: List<ImplementationKindOwner> get() = listOf(element)
|
||||
val isDefault = name == null
|
||||
override val typeName = name ?: (element.typeName + "Impl")
|
||||
|
||||
-2
@@ -159,7 +159,6 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
println()
|
||||
withIndent {
|
||||
for (field in walkableFields) {
|
||||
check(field is FieldWithDefault)
|
||||
when (field.name) {
|
||||
"explicitReceiver" -> {
|
||||
val explicitReceiver = implementation["explicitReceiver"]!!
|
||||
@@ -226,7 +225,6 @@ fun SmartPrinter.printImplementation(implementation: Implementation) {
|
||||
if (!isInterface && !isAbstract) {
|
||||
printBlock {
|
||||
for (field in transformableChildren) {
|
||||
check(field is FieldWithDefault)
|
||||
when {
|
||||
field.name == "explicitReceiver" -> {
|
||||
val explicitReceiver = implementation["explicitReceiver"]!!
|
||||
|
||||
Reference in New Issue
Block a user