[4.2] Space Engine: uninhabited types map to empty spaces #17690
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation: In adding
@unknown default
, the switch statement exhaustivity checking started complaining about missing enum cases where the payload type was uninhabited (likeOptional<Never>.some(_)
). It's clearly unnecessary for a user to have to match that case, and so this patch detects it earlier and avoids even adding thesome
case to the list of possible enum values. This may also very slightly speed up switch statement checking.Scope: Affects switch statement checking of enums when one of the case payload types is uninhabited.
Issue: SR-8125 / rdar://problem/41525746
Risk: Medium-low. This does affect switch exhaustivity checking, which means we could see more "case is redundant" diagnostics in addition to removing the unwanted "missing case" diagnostic. However, the change is correct from the perspective of the algorithm.
Testing: Added compiler regression tests, verified that the original project builds successfully.
Reviewed by: @CodaFi, @xedin