Skip to content

AST: Fix a couple _diagnoseUnavailableCodeReached() crashes for zippered libraries #72858

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

Conversation

tshortli
Copy link
Contributor

@tshortli tshortli commented Apr 4, 2024

The declarations in a zippered macOS library may be referenced by clients that build either for macOS or for macCatalyst. It is therefore inappropriate to stub functions in zippered libraries as "unreachable" when they are only unavailable on macOS. The same issue also affects the derived Hashable and Equatable conformances for enums with unavailable elements. Making this logic correct is a larger project, so for now we're more conservative about classifying a declaration as unreachable when a target variant is present during compilation.

Resolves rdar://125371621

tshortli added 2 commits April 4, 2024 16:18
The declarations in a zippered macOS library may be referenced by clients that
build either for macOS or for macCatalyst. It is therefore inappropriate to
stub functions in zippered libraries as "unreachable" when they are only
unavailable on macOS. Making this logic correct is a larger project, so for now
just disable stubbing when there is a target variant.

Resolves rdar://125371621
…ivation.

When deriving `Hashable` and `Equatable` for enums, use
`Decl::isUnreachableAtRuntime()` to determine whether or not to insert
`_diagnoseUnavailableCodeReached()` traps for specific enum elements. This
fixes a bug where inappropriate traps were inserted for enum elements that are
unavailable for app extensions. It also fixes a bug where traps were inserted
when building a zippered library for macOS and enum elements were unavailable
on macOS but not for macCatalyst clients.

Resolves rdar://125371621
@tshortli
Copy link
Contributor Author

tshortli commented Apr 4, 2024

@swift-ci please smoke test

@tshortli tshortli merged commit a6aa2dc into swiftlang:main Apr 5, 2024
@tshortli tshortli deleted the maccatalyst-unavailable-decl-stubs branch April 5, 2024 16:35
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