I have a rather long switch over tuple of 3 enums, resulting in 439 cases to be exhaustive. ~1/3 of them is matched with a wildcard.
The compiler is complaining with The compiler is unable to check that this switch is exhaustive in reasonable time error and is suggesting Add a default clause fixit. When I do so the compiler immediately emits warning over the default clause that Default will never be executed–which is correct, I'm exhaustive and testing over all possible cases doesn't hit the fatalError in the default. Then when I remove the default clause it immediately emits the former error.
The speed of the diagnostic doesn't sound like "unreasonable time" and at the same time it obviously can check the exhaustivity.
To avoid both the error and the warning, remove the last case and replace it with default (you can assert in the body that the match is what you expect and fatalError otherwise).
I certainly want to avoid the default clause, as I want the compiler to check for exhaustivity—these my enums might get new members in the future.
Luckily, in my case, I can afford to split it. However, I was hoping for some frontend fix, like increasing the threshold time, but I can’t find any annotation or setting flag. I recall being able to do something like that back in Obj-C. The compiler is apparently able to perform the check in an instant.
/// If non-zero, abort the switch statement exhaustiveness checker if
/// the Space::minus function is called more than this many times.
///
/// Why this number? Times out in about a second on a 2017 iMac, Retina 5K,
/// 4.2 GHz Intel Core i7.
/// (It's arbitrary, but will keep the compiler from taking too much time.)
unsigned SwitchCheckingInvocationThreshold = 200000;
However, it' s not wired up to a command line flag. If someone wants to take a look, it should be straightforward to add a flag to FrontendOptions.td and wire it up to set the above struct field in CompilerInvocation.cpp.