[IR] Add optIn to IrDeclarationContainer.declarations

Accessing list of declaration may trigger lazy declaration list computation for lazy class,
   which requires computation of fake-overrides for this class. So it's unsafe to access it
   before IR for all sources is built (because fake-overrides of lazy classes may depend on
   declaration of source classes, e.g. for java source classes)

So this OptIn is needed to carefully handle all cases of .declarations access in FIR2IR
This commit is contained in:
Dmitriy Novozhilov
2023-10-06 14:47:16 +03:00
committed by Space Team
parent 3556533d95
commit c8b7dbd352
8 changed files with 32 additions and 2 deletions
@@ -343,7 +343,17 @@ object IrTree : AbstractTreeBuilder() {
parent(declarationParent)
+listField("declarations", declaration, mutability = List, isChild = true)
+listField("declarations", declaration, mutability = List, isChild = true) {
kDoc = """
Accessing list of declaration may trigger lazy declaration list computation for lazy class,
which requires computation of fake-overrides for this class. So it's unsafe to access it
before IR for all sources is built (because fake-overrides of lazy classes may depend on
declaration of source classes, e.g. for java source classes)
""".trimIndent()
generationCallback = {
addAnnotation(ClassName("org.jetbrains.kotlin.ir.symbols", "IrSymbolInternals"))
}
}
}
val typeParametersContainer: ElementConfig by element(Declaration) {
ownsChildren = false