Skip to content

Serialization: Protect deserializeEnum and more against failures #80108

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 6 commits into from
Mar 20, 2025

Conversation

xymus
Copy link
Contributor

@xymus xymus commented Mar 19, 2025

Recover from a raw type hidden behind an internal or implementation-only import by dropping the whole enum when the raw type is not visible. This scenario should happen only when looking at non-public decl for indexing or debugging, or if dependencies somehow changed and left behind a stale swiftmodule file.

Apply the same recovery logic to other notable uses of getType at deserializing a class or parameter.

Also clean up a few related pieces of code. Rename the macro UNWRAP to SET_OR_RETURN_ERROR for clarity and invert its parameters to have a more intuitive order of assignment target and then expression. And update the multipurpose test implementation-only-missing.swift to use split-file.

rdar://147091863

@xymus
Copy link
Contributor Author

xymus commented Mar 19, 2025

@swift-ci Please smoke test

xymus added 3 commits March 19, 2025 14:10
Rename the macro UNWRAP to SET_OR_RETURN_ERROR for clarity and invert its
parameters to have a more intuitive order of assignment target and then
expression.
Recover from a raw type hidden behind an internal or implementation-only
import by dropping the whole enum when the raw type is unavailable. This
scenario should happen only when looking at non-public decl for indexing or
debugging, or if dependencies somehow changed and left behind a stale
swiftmodule file.

rdar://147091863
@xymus xymus force-pushed the deser-protect-enum-raw-type branch from b6733fe to 0ac3f04 Compare March 19, 2025 21:12
@xymus
Copy link
Contributor Author

xymus commented Mar 19, 2025

@swift-ci Please smoke test

@xymus xymus requested a review from bnbarham March 19, 2025 21:13
Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

Thanks 🙇‍♂️

@xymus xymus force-pushed the deser-protect-enum-raw-type branch from 0ac3f04 to 4615615 Compare March 19, 2025 23:27
@xymus
Copy link
Contributor Author

xymus commented Mar 19, 2025

@swift-ci Please smoke test

@xymus xymus merged commit 2086df0 into swiftlang:main Mar 20, 2025
3 checks passed
@xymus xymus deleted the deser-protect-enum-raw-type branch March 20, 2025 16:04
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