[FIR] Make FirFile.annotationsContainer nullable

Previously, when no file annotations were present, the FIR element
didn't have a source.
By making it nullable, it will only be created when appropriate and the
source will never be null.

#KT-55835
This commit is contained in:
Kirill Rakhman
2023-06-26 15:06:13 +03:00
committed by Space Team
parent 311975f1ed
commit bed6cb7154
334 changed files with 47 additions and 1937 deletions
@@ -41,6 +41,10 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
fields from klass without listOf("symbol", "resolvePhase", "resolveState", "controlFlowGraphReference")
}
builder(file) {
defaultNull("annotationsContainer")
}
builder(regularClass) {
parents += classBuilder
parents += typeParameterRefsOwnerBuilder
@@ -609,7 +609,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
impl(file) {
default("annotations") {
value = "annotationsContainer.annotations"
value = "annotationsContainer?.annotations ?: emptyList()"
withGetter = true
}
}
@@ -477,7 +477,7 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
}
file.configure {
+field("annotationsContainer", fileAnnotationsContainer).withTransform()
+field("annotationsContainer", fileAnnotationsContainer, nullable = true).withTransform()
+field("packageDirective", packageDirective)
+fieldList(import).withTransform()
+declarations.withTransform()