a3c696fa58
When determining whether a switch statement is exhaustive, it's important for the exhaustiveness algorithm to ignore cases containing `when` clauses, since a `when` clause creates the possiblity that the case won't match. Previously, the way this was done in the analyzer was for the `SpaceCreator.createRootSpace` method to create an unknown space for cases containing `when` clauses. This approach produced the correct behavior when determining whether the switch statement as a whole was exhaustive, but since it discarded information about the pattern being matched, it limited the ability to determine whether an individual case was reachable, leading to https://github.com/dart-lang/sdk/issues/56710. To fix this, `SpaceCreator.createRootSpace` is changed so that it always produces a space that describes the case pattern, regardless of whether a `when` clause is present, and instead, `computeExhaustiveness` is responsible for ensuring that the case is properly excluded from the determination of whether the switch is exhaustive. This allows `computeExhaustiveness` to properly computate whether each individual case is reachable, even for cases that have `when` clauses. This change in approach produced some minor differences in the test cases in `pkg/_fe_analyzer_shared/test/exhaustiveness/data`, but these differences are not user-observable. Fixes https://github.com/dart-lang/sdk/issues/56710. Change-Id: I36629a77c4c1832fb1b8abb6ea7b109e0ca14373 Bug: https://github.com/dart-lang/sdk/issues/56710 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384326 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Paul Berry <paulberry@google.com>