mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When built as part of the compiler toolchain SwiftSyntax is built with library evolution enabled. This means that switches over enums from SwiftSyntax must include a default case to be considered exhaustive, or a warning will be emitted. This change suppresses those warnings by adding `@unknown default` cases wherever they are expected. As a compromise, these `@unknown default` cases are wrapped with a `#if` to ensure they are only included in the CMake build of ASTGen, but continue to be omitted from the SPM build which compiler engineers use to iterate on ASTGen's implementation. This is needed to avoid generating the opposite warning during the SPM build, since the compiler thinks the `@unknown default` case is superfluous when SwiftSyntax is built non-resiliently. As an aside, this catch-22 is a bummer and I think we should change the compiler to suppress the unreachable default warning when the default is annotated `@unknown`.