FIR: use FirCachesFactory for package type alias in KotlinDeserializedJvmSymbolsProvider
This commit is contained in:
+12
-10
@@ -50,7 +50,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
|||||||
private val kotlinScopeProvider: KotlinScopeProvider,
|
private val kotlinScopeProvider: KotlinScopeProvider,
|
||||||
) : FirSymbolProvider(session) {
|
) : FirSymbolProvider(session) {
|
||||||
private val annotationsLoader = AnnotationsLoader(session)
|
private val annotationsLoader = AnnotationsLoader(session)
|
||||||
private val typeAliasCache = SymbolProviderCache<ClassId, FirTypeAliasSymbol>()
|
private val typeAliasCache = session.firCachesFactory.createCache(::findAndDeserializeTypeAlias)
|
||||||
private val packagePartsCache = SymbolProviderCache<FqName, Collection<PackagePartsCacheData>>()
|
private val packagePartsCache = SymbolProviderCache<FqName, Collection<PackagePartsCacheData>>()
|
||||||
|
|
||||||
private val classCache =
|
private val classCache =
|
||||||
@@ -131,20 +131,22 @@ class KotlinDeserializedJvmSymbolsProvider(
|
|||||||
get() = classHeader.isPreRelease
|
get() = classHeader.isPreRelease
|
||||||
|
|
||||||
override fun getClassLikeSymbolByFqName(classId: ClassId): FirClassLikeSymbol<*>? {
|
override fun getClassLikeSymbolByFqName(classId: ClassId): FirClassLikeSymbol<*>? {
|
||||||
return getClass(classId) ?: findAndDeserializeTypeAlias(classId)
|
return getClass(classId) ?: getTypeAlias(classId)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findAndDeserializeTypeAlias(
|
private fun getTypeAlias(
|
||||||
classId: ClassId,
|
classId: ClassId,
|
||||||
): FirTypeAliasSymbol? {
|
): FirTypeAliasSymbol? {
|
||||||
if (!classId.relativeClassName.isOneSegmentFQN()) return null
|
if (!classId.relativeClassName.isOneSegmentFQN()) return null
|
||||||
return typeAliasCache.lookupCacheOrCalculate(classId) {
|
return typeAliasCache.getValue(classId)
|
||||||
getPackageParts(classId.packageFqName).firstNotNullResult { part ->
|
}
|
||||||
val ids = part.typeAliasNameIndex[classId.shortClassName]
|
|
||||||
if (ids == null || ids.isEmpty()) return@firstNotNullResult null
|
private fun findAndDeserializeTypeAlias(classId: ClassId): FirTypeAliasSymbol? {
|
||||||
val aliasProto = ids.map { part.proto.getTypeAlias(it) }.single()
|
return getPackageParts(classId.packageFqName).firstNotNullResult { part ->
|
||||||
part.context.memberDeserializer.loadTypeAlias(aliasProto).symbol
|
val ids = part.typeAliasNameIndex[classId.shortClassName]
|
||||||
}
|
if (ids == null || ids.isEmpty()) return@firstNotNullResult null
|
||||||
|
val aliasProto = ids.map { part.proto.getTypeAlias(it) }.single()
|
||||||
|
part.context.memberDeserializer.loadTypeAlias(aliasProto).symbol
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user