[fir2ir] Use the correct 'FirProvider' for fetching the containing file
In the IDE, declarations may come from different modules.
This commit is contained in:
@@ -44,8 +44,6 @@ class Fir2IrClassifierStorage(
|
|||||||
private val components: Fir2IrComponents,
|
private val components: Fir2IrComponents,
|
||||||
commonMemberStorage: Fir2IrCommonMemberStorage
|
commonMemberStorage: Fir2IrCommonMemberStorage
|
||||||
) : Fir2IrComponents by components {
|
) : Fir2IrComponents by components {
|
||||||
private val firProvider = session.firProvider
|
|
||||||
|
|
||||||
private val classCache: MutableMap<FirRegularClass, IrClass> = commonMemberStorage.classCache
|
private val classCache: MutableMap<FirRegularClass, IrClass> = commonMemberStorage.classCache
|
||||||
|
|
||||||
private val localClassesCreatedOnTheFly: MutableMap<FirClass, IrClass> = mutableMapOf()
|
private val localClassesCreatedOnTheFly: MutableMap<FirClass, IrClass> = mutableMapOf()
|
||||||
@@ -237,7 +235,7 @@ class Fir2IrClassifierStorage(
|
|||||||
// finding the parent class that actually contains the [klass] in the tree - it is the root one that should be created on the fly
|
// finding the parent class that actually contains the [klass] in the tree - it is the root one that should be created on the fly
|
||||||
val classOrLocalParent = generateSequence(klass) { c ->
|
val classOrLocalParent = generateSequence(klass) { c ->
|
||||||
(c as? FirRegularClass)?.containingClassForLocalAttr?.let { lookupTag ->
|
(c as? FirRegularClass)?.containingClassForLocalAttr?.let { lookupTag ->
|
||||||
(firProvider.symbolProvider.getSymbolByLookupTag(lookupTag)?.fir as? FirClass)?.takeIf {
|
(session.firProvider.symbolProvider.getSymbolByLookupTag(lookupTag)?.fir as? FirClass)?.takeIf {
|
||||||
it.declarations.contains(c)
|
it.declarations.contains(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -528,7 +526,9 @@ class Fir2IrClassifierStorage(
|
|||||||
predefinedOrigin: IrDeclarationOrigin? = null,
|
predefinedOrigin: IrDeclarationOrigin? = null,
|
||||||
): IrEnumEntry {
|
): IrEnumEntry {
|
||||||
getCachedIrEnumEntry(enumEntry)?.let { return it }
|
getCachedIrEnumEntry(enumEntry)?.let { return it }
|
||||||
val containingFile = firProvider.getFirCallableContainerFile(enumEntry.symbol)
|
|
||||||
|
val firProviderForEntry = enumEntry.moduleData.session.firProvider
|
||||||
|
val containingFile = firProviderForEntry.getFirCallableContainerFile(enumEntry.symbol)
|
||||||
|
|
||||||
@Suppress("NAME_SHADOWING")
|
@Suppress("NAME_SHADOWING")
|
||||||
val predefinedOrigin = predefinedOrigin ?: if (containingFile != null) {
|
val predefinedOrigin = predefinedOrigin ?: if (containingFile != null) {
|
||||||
@@ -618,7 +618,8 @@ class Fir2IrClassifierStorage(
|
|||||||
}
|
}
|
||||||
val irClass = firClass.convertWithOffsets { startOffset, endOffset ->
|
val irClass = firClass.convertWithOffsets { startOffset, endOffset ->
|
||||||
declareIrClass(signature) { irClassSymbol ->
|
declareIrClass(signature) { irClassSymbol ->
|
||||||
Fir2IrLazyClass(components, startOffset, endOffset, firClass.irOrigin(firProvider), firClass, irClassSymbol).apply {
|
val firClassOrigin = firClass.irOrigin(session.firProvider)
|
||||||
|
Fir2IrLazyClass(components, startOffset, endOffset, firClassOrigin, firClass, irClassSymbol).apply {
|
||||||
parent = irParent
|
parent = irParent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -74,8 +74,6 @@ class Fir2IrDeclarationStorage(
|
|||||||
commonMemberStorage: Fir2IrCommonMemberStorage
|
commonMemberStorage: Fir2IrCommonMemberStorage
|
||||||
) : Fir2IrComponents by components {
|
) : Fir2IrComponents by components {
|
||||||
|
|
||||||
private val firProvider = session.firProvider
|
|
||||||
|
|
||||||
private val fragmentCache: ConcurrentHashMap<FqName, ExternalPackageFragments> = ConcurrentHashMap()
|
private val fragmentCache: ConcurrentHashMap<FqName, ExternalPackageFragments> = ConcurrentHashMap()
|
||||||
|
|
||||||
private class ExternalPackageFragments(
|
private class ExternalPackageFragments(
|
||||||
@@ -1818,8 +1816,11 @@ class Fir2IrDeclarationStorage(
|
|||||||
return when (val firDeclaration = firVariableSymbol.fir) {
|
return when (val firDeclaration = firVariableSymbol.fir) {
|
||||||
is FirEnumEntry -> {
|
is FirEnumEntry -> {
|
||||||
classifierStorage.getCachedIrEnumEntry(firDeclaration)?.let { return it.symbol }
|
classifierStorage.getCachedIrEnumEntry(firDeclaration)?.let { return it.symbol }
|
||||||
val containingFile = firProvider.getFirCallableContainerFile(firVariableSymbol)
|
|
||||||
val irParentClass = firDeclaration.containingClassLookupTag()?.let { classifierStorage.findIrClass(it) }
|
val irParentClass = firDeclaration.containingClassLookupTag()?.let { classifierStorage.findIrClass(it) }
|
||||||
|
|
||||||
|
val firProviderForSymbol = firVariableSymbol.moduleData.session.firProvider
|
||||||
|
val containingFile = firProviderForSymbol.getFirCallableContainerFile(firVariableSymbol)
|
||||||
|
|
||||||
classifierStorage.createIrEnumEntry(
|
classifierStorage.createIrEnumEntry(
|
||||||
firDeclaration,
|
firDeclaration,
|
||||||
irParent = irParentClass,
|
irParent = irParentClass,
|
||||||
|
|||||||
Reference in New Issue
Block a user