[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.
This commit is contained in:
Marco Pennekamp
2023-11-10 13:44:06 +01:00
committed by Space Team
parent 0be566f6b6
commit d89e29f289
@@ -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].