FIR2IR: Introduce and use declarationStorage.getOrCreateIrConstructor

It's necessary because constructors of LazyIrClass annotations may be
referenced before members are processed
This commit is contained in:
Denis.Zharkov
2021-02-17 18:40:23 +03:00
parent fb8314f6e7
commit d339096ac3
2 changed files with 12 additions and 2 deletions
@@ -123,7 +123,7 @@ class Fir2IrConverter(
irClass: IrClass = classifierStorage.getCachedIrClass(regularClass)!!
): IrClass {
val irConstructor = regularClass.getPrimaryConstructorIfAny()?.let {
declarationStorage.createIrConstructor(it, irClass, isLocal = regularClass.isLocal)
declarationStorage.getOrCreateIrConstructor(it, irClass, isLocal = regularClass.isLocal)
}
if (irConstructor != null) {
irClass.declarations += irConstructor
@@ -219,7 +219,7 @@ class Fir2IrConverter(
}
}
is FirConstructor -> if (!declaration.isPrimary) {
declarationStorage.createIrConstructor(
declarationStorage.getOrCreateIrConstructor(
declaration, parent as IrClass, isLocal = isLocal
)
} else {
@@ -544,6 +544,16 @@ class Fir2IrDeclarationStorage(
return created
}
fun getOrCreateIrConstructor(
constructor: FirConstructor,
irParent: IrClass,
origin: IrDeclarationOrigin = IrDeclarationOrigin.DEFINED,
isLocal: Boolean = false
): IrConstructor {
getCachedIrConstructor(constructor)?.let { return it }
return createIrConstructor(constructor, irParent, origin, isLocal)
}
private fun declareIrAccessor(
signature: IdSignature?,
containerSource: DeserializedContainerSource?,