Skip to content

[Sema] Remove @unknown default requirement for package enums. #75872

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

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

elsh
Copy link
Contributor

@elsh elsh commented Aug 13, 2024

@unknown default in switch statements are required for resilient enums since they might be modified with new fields in the future and modules defining the enums are generally not built together with the consuming modules.

However, if the modules are in the same package, they are required to be built together, thus the requirement for @unknown default can be skipped. This PR removes the need for that, enabling less boilerplate. Note this change only impacts typecheck and not SIL gen.

Resolves rdar://130015149.

@elsh
Copy link
Contributor Author

elsh commented Aug 13, 2024

@swift-ci smoke test

@elsh elsh requested review from nkcsgexi, artemcm and tshortli August 13, 2024 23:25
Copy link
Contributor

@nkcsgexi nkcsgexi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change makes sense to me. Thank you for the exhaustive test case!

`@unknown default` in switch statements are required for resilient enums since they
might be modified with new fields in the future and modules defining the enums are
generally not built together with the consuming modules.

However, if the modules are in the same package, they are required to be built together,
thus the requirement for `@unknown default` can be skipped. This PR removes the need for
that, enabling less boilerplate. Note this change only impacts typecheck and not SIL gen.

Resolves rdar://130015149.
@elsh elsh force-pushed the elsh/pkg-switch-enum branch from 8341e4b to fadf6ec Compare August 14, 2024 00:06
@elsh
Copy link
Contributor Author

elsh commented Aug 14, 2024

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Aug 14, 2024

pending #75745 as new test covers interface flag related changes.

@elsh
Copy link
Contributor Author

elsh commented Aug 14, 2024

@swift-ci smoke test

@elsh
Copy link
Contributor Author

elsh commented Aug 14, 2024

@swift-ci smoke test linux

@elsh elsh enabled auto-merge August 14, 2024 21:32
@elsh elsh disabled auto-merge August 14, 2024 21:32
@elsh
Copy link
Contributor Author

elsh commented Aug 14, 2024

@swift-ci smoke test linux

1 similar comment
@elsh
Copy link
Contributor Author

elsh commented Aug 15, 2024

@swift-ci smoke test linux

@elsh elsh enabled auto-merge August 15, 2024 09:21
@elsh elsh merged commit 93f9a17 into main Aug 15, 2024
3 checks passed
@elsh elsh deleted the elsh/pkg-switch-enum branch August 15, 2024 12:48
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