[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
@@ -46,6 +46,21 @@ class FirExtensionSyntheticFunctionInterfaceProvider(
moduleData: FirModuleData,
kotlinScopeProvider: FirKotlinScopeProvider
) : FirSyntheticFunctionInterfaceProviderBase(session, moduleData, kotlinScopeProvider) {
companion object {
/**
* A [FirExtensionSyntheticFunctionInterfaceProvider] only needs to be created if the session's function type service has extension
* function kinds. Otherwise, the provider would be useless.
*/
fun createIfNeeded(
session: FirSession,
moduleData: FirModuleData,
kotlinScopeProvider: FirKotlinScopeProvider,
): FirExtensionSyntheticFunctionInterfaceProvider? {
if (!session.functionTypeService.hasExtensionKinds()) return null
return FirExtensionSyntheticFunctionInterfaceProvider(session, moduleData, kotlinScopeProvider)
}
}
override fun FunctionTypeKind.isAcceptable(): Boolean {
return !this.isBuiltin
}