[LL FIR] KT-57220 Optimize & combine synthetic function symbol providers
- Dependency symbol providers contained a lot of useless `FirExtensionSyntheticFunctionInterfaceProvider`s, because such a provider only generates function classes from compiler plugins. If there aren't any such `FunctionTypeKind`s in the session, there is no need to even add the provider. - `FirExtensionSyntheticFunctionInterfaceProvider`s that are added to the list of dependency providers despite this optimization will now be combined in `LLFirCombinedSyntheticFunctionSymbolProvider`. It checks `ClassId` heuristics once, which is more efficient than checking them in every provider separately.
This commit is contained in:
committed by
Space Team
parent
09ab192205
commit
2d85e9db51
+8
-1
@@ -69,11 +69,15 @@ abstract class FirSyntheticFunctionInterfaceProviderBase(
|
||||
val moduleData: FirModuleData,
|
||||
val kotlinScopeProvider: FirKotlinScopeProvider
|
||||
) : FirSymbolProvider(session) {
|
||||
@OptIn(FirSymbolProviderInternals::class)
|
||||
override fun getClassLikeSymbolByClassId(classId: ClassId): FirRegularClassSymbol? {
|
||||
if (!classId.mayBeSyntheticFunctionClassName()) return null
|
||||
return cache.getValue(classId)
|
||||
return getClassLikeSymbolByClassIdWithoutClassIdChecks(classId)
|
||||
}
|
||||
|
||||
@FirSymbolProviderInternals
|
||||
fun getClassLikeSymbolByClassIdWithoutClassIdChecks(classId: ClassId): FirRegularClassSymbol? = cache.getValue(classId)
|
||||
|
||||
@FirSymbolProviderInternals
|
||||
override fun getTopLevelCallableSymbolsTo(destination: MutableList<FirCallableSymbol<*>>, packageFqName: FqName, name: Name) {
|
||||
}
|
||||
@@ -86,6 +90,9 @@ abstract class FirSyntheticFunctionInterfaceProviderBase(
|
||||
override fun getTopLevelPropertySymbolsTo(destination: MutableList<FirPropertySymbol>, packageFqName: FqName, name: Name) {
|
||||
}
|
||||
|
||||
@FirSymbolProviderInternals
|
||||
fun getFunctionKindPackageNames(): Set<FqName> = session.functionTypeService.getFunctionKindPackageNames()
|
||||
|
||||
override fun getPackage(fqName: FqName): FqName? {
|
||||
return fqName.takeIf { session.functionTypeService.hasKindWithSpecificPackage(it) }
|
||||
}
|
||||
|
||||
@@ -23,6 +23,16 @@ abstract class FirFunctionTypeKindService : FirSessionComponent {
|
||||
return extractor.hasKindWithSpecificPackage(packageFqName)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all package names for which [getKindByClassNamePrefix] may return a [FunctionTypeKind].
|
||||
*/
|
||||
fun getFunctionKindPackageNames(): Set<FqName> = extractor.getFunctionKindPackageNames()
|
||||
|
||||
/**
|
||||
* Whether [getKindByClassNamePrefix] may return a [FunctionTypeKind] added by a compiler plugin.
|
||||
*/
|
||||
fun hasExtensionKinds(): Boolean = extractor.hasExtensionKinds()
|
||||
|
||||
abstract fun extractSingleSpecialKindForFunction(functionSymbol: FirFunctionSymbol<*>): FunctionTypeKind?
|
||||
abstract fun extractAllSpecialKindsForFunction(functionSymbol: FirFunctionSymbol<*>): List<FunctionTypeKind>
|
||||
abstract fun extractAllSpecialKindsForFunctionTypeRef(typeRef: FirFunctionTypeRef): List<FunctionTypeKind>
|
||||
|
||||
Reference in New Issue
Block a user