[FIR] Add special node for sealed classes
This commit is contained in:
+1
@@ -43,6 +43,7 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
|
||||
val klass = element("Class", Declaration, declaration, statement, annotationContainer)
|
||||
val classLikeDeclaration = element("ClassLikeDeclaration", Declaration, statement, memberDeclaration, symbolOwner, typeParametersOwner)
|
||||
val regularClass = element("RegularClass", Declaration, namedDeclaration, classLikeDeclaration, klass)
|
||||
val sealedClass = element("SealedClass", Declaration, regularClass)
|
||||
val typeAlias = element("TypeAlias", Declaration, classLikeDeclaration)
|
||||
val enumEntry = element("EnumEntry", Declaration, regularClass)
|
||||
|
||||
|
||||
+9
-1
@@ -61,12 +61,20 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
kind = Interface
|
||||
}
|
||||
|
||||
impl(regularClass, "FirClassImpl") {
|
||||
val modifiableRegularClass = impl(regularClass, "FirModifiableRegularClass") {
|
||||
parents += modifiableClass
|
||||
parents += modifiableTypeParametersOwner
|
||||
kind = Interface
|
||||
}
|
||||
|
||||
val regularClassConfig: ImplementationContext.() -> Unit = {
|
||||
parents += modifiableRegularClass
|
||||
defaultNull("companionObject")
|
||||
defaultSupertypesComputationStatus()
|
||||
}
|
||||
impl(regularClass, "FirClassImpl", regularClassConfig)
|
||||
|
||||
impl(sealedClass, config = regularClassConfig)
|
||||
|
||||
impl(anonymousObject) {
|
||||
parents += modifiableClass
|
||||
|
||||
+4
@@ -220,6 +220,10 @@ object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
+superTypeRefs(withReplace = true)
|
||||
}
|
||||
|
||||
sealedClass.configure {
|
||||
+fieldList("inheritors", classIdType, withReplace = true)
|
||||
}
|
||||
|
||||
typeAlias.configure {
|
||||
parentArg(classLikeDeclaration, "F", typeAlias)
|
||||
+symbol("FirTypeAliasSymbol")
|
||||
|
||||
+3
-3
@@ -289,7 +289,7 @@ fun PrintWriter.printImplementation(implementation: Implementation) {
|
||||
}
|
||||
}
|
||||
|
||||
element.allFields.filter { it.type.contains("Symbol") }
|
||||
element.allFields.filter { it.type.contains("Symbol") && it !is FieldList }
|
||||
.takeIf { it.isNotEmpty() && !isInterface && !element.type.contains("Reference")}
|
||||
?.let { symbolFields ->
|
||||
indent(1)
|
||||
@@ -338,7 +338,7 @@ fun PrintWriter.printImplementation(implementation: Implementation) {
|
||||
}
|
||||
|
||||
else -> {
|
||||
if (type == "FirClassImpl" && field.name == "declarations") {
|
||||
if (type in setOf("FirClassImpl", "FirSealedClassImpl") && field.name == "declarations") {
|
||||
indent(2)
|
||||
println("(declarations.firstOrNull { it is FirConstructorImpl } as? FirConstructorImpl)?.typeParameters?.forEach { it.accept(visitor, data) }")
|
||||
}
|
||||
@@ -413,7 +413,7 @@ fun PrintWriter.printImplementation(implementation: Implementation) {
|
||||
}
|
||||
field.name in setOf("dispatchReceiver", "extensionReceiver") -> {
|
||||
}
|
||||
type == "FirClassImpl" && field.name == "declarations" -> {
|
||||
type in setOf("FirClassImpl", "FirSealedClassImpl") && field.name == "declarations" -> {
|
||||
indent(2)
|
||||
println("(declarations.firstOrNull { it is FirConstructorImpl } as? FirConstructorImpl)?.typeParameters?.transformInplace(transformer, data)")
|
||||
indent(2)
|
||||
|
||||
+2
-1
@@ -58,4 +58,5 @@ val compositeTransformResultType = type("fir.visitors", "CompositeTransformResul
|
||||
|
||||
val abstractFirBasedSymbolType = type("fir.symbols", "AbstractFirBasedSymbol")
|
||||
val backingFieldSymbolType = type("fir.symbols.impl", "FirBackingFieldSymbol")
|
||||
val delegateFieldSymbolType = type("fir.symbols.impl", "FirDelegateFieldSymbol")
|
||||
val delegateFieldSymbolType = type("fir.symbols.impl", "FirDelegateFieldSymbol")
|
||||
val classSymbolType = type("fir.symbols.impl", "FirClassSymbol")
|
||||
Reference in New Issue
Block a user