[FIR] KT-57220 Avoid creating useless synthetic function providers

- This optimization applied to LL FIR can be extended to K2 as a whole.
  Likely, there won't be any performance benefits in CLI runs, but it's
  still better to avoid useless symbol providers.
This commit is contained in:
Marco Pennekamp
2023-03-15 15:46:35 +01:00
committed by Space Team
parent 2d85e9db51
commit d9f515fbb8
6 changed files with 47 additions and 24 deletions
@@ -164,13 +164,8 @@ internal class LLFirSessionCache(private val project: Project) {
})
val javaSymbolProvider = createJavaSymbolProvider(this, moduleData, project, contentScope)
// We only need to add an extension synthetic function provider if the session's function type service even has extension kinds.
// Otherwise, the provider will be completely useless.
val syntheticFunctionalInterfaceProvider = if (this.functionTypeService.hasExtensionKinds()) {
FirExtensionSyntheticFunctionInterfaceProvider(this, moduleData, scopeProvider)
} else null
val syntheticFunctionInterfaceProvider =
FirExtensionSyntheticFunctionInterfaceProvider.createIfNeeded(this, moduleData, scopeProvider)
register(
FirSymbolProvider::class,
LLFirModuleWithDependenciesSymbolProvider(
@@ -179,7 +174,7 @@ internal class LLFirSessionCache(private val project: Project) {
provider.symbolProvider,
switchableExtensionDeclarationsSymbolProvider,
javaSymbolProvider,
syntheticFunctionalInterfaceProvider,
syntheticFunctionInterfaceProvider,
),
dependencyProvider,
)