[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:
Marco Pennekamp
2023-03-09 20:00:02 +01:00
committed by Space Team
parent 09ab192205
commit 2d85e9db51
5 changed files with 101 additions and 6 deletions
@@ -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) }
}