Skip to content

[4.2] Space Engine: uninhabited types map to empty spaces #17690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Jul 3, 2018

  • Explanation: In adding @unknown default, the switch statement exhaustivity checking started complaining about missing enum cases where the payload type was uninhabited (like Optional<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 the some 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

Without this, the compiler ended up complaining about missing cases
that can't actually occur, like `Optional<Never>.some(_)`. This was a
regression from Swift 4.1.

https://bugs.swift.org/browse/SR-8125
(cherry picked from commit e783027)
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please nominate

@slavapestov
Copy link
Contributor

Cool, now we can typealias Void = Optional<Never>!

@jrose-apple jrose-apple merged commit 107e307 into swiftlang:swift-4.2-branch Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants