From d89e29f2895dbb73482b324abb2e06e3344bee8b Mon Sep 17 00:00:00 2001 From: Marco Pennekamp Date: Fri, 10 Nov 2023 13:44:06 +0100 Subject: [PATCH] [FIR] FirSymbolNamesProvider: Provide default implementation for `mayHaveSyntheticFunctionType` - Composite providers may call `mayHaveSyntheticFunctionType` on *all* of their children if *one* child has `mayHaveSyntheticFunctionTypes == true`, so `mayHaveSyntheticFunctionType` should have a proper default implementation to avoid runtime errors. - The alternative of requiring to check `mayHaveSyntheticFunctionTypes` before calling `mayHaveSyntheticFunctionType` at the call-site was considered, but deemed too error-prone. Given that `mayHaveSyntheticFunctionType` is an optimization and admits false positives, an imprecise default implementation of it is allowed. Thanks to Mikhail Glukhikh for discovering this problem. --- .../kotlin/fir/resolve/providers/FirSymbolNamesProvider.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/providers/FirSymbolNamesProvider.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/providers/FirSymbolNamesProvider.kt index d79a896bf6a..5fa8114503a 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/providers/FirSymbolNamesProvider.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/providers/FirSymbolNamesProvider.kt @@ -63,8 +63,7 @@ abstract class FirSymbolNamesProvider { /** * Whether [classId] is considered a generated function type within the provider's scope and session. */ - open fun mayHaveSyntheticFunctionType(classId: ClassId): Boolean = - error("`mayHaveSyntheticFunctionType` needs to be implemented when `mayHaveSyntheticFunctionTypes` is true.") + open fun mayHaveSyntheticFunctionType(classId: ClassId): Boolean = mayHaveSyntheticFunctionTypes /** * Checks if the provider's scope may contain a top-level classifier (class, interface, object, or type alias) with the given [classId].