Skip to content

[6.0 🍒] Apply the @_alwaysEmitConformanceMetadata semantics to conformances originating from macro-expanded declarations and extensions #73681

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

artemcm
Copy link
Contributor

@artemcm artemcm commented May 16, 2024

Cherry-pick of #73680

Explanation: The attribute added in #60367 causes the compiler to ensure that conformances to protocols annotated with the @_alwaysEmitConformanceMetadata attribute are in the resulting binaries even if the conformance itself is not public or even used elsewhere in the code. The current implementation (#69609) of this attribute does not account that such conformances may originate from macro-expansions. This change fixes that by causing the detection logic to consider macro-expanded contexts.

Risk: Low. This change extends the existing declaration walker by causing it to also walk macro-expanded declarations in order to find conformances to attribute annotated protocols. For code not annotated with this attribute this will not result in any changes. And for code that is annotated, the produced binaries will contain the expected results, whereas they did not before.

Testing: Automated test added to the compiler test suite.

Resolves rdar://127903662

… originating from macro-expanded declarations and extensions

Existing code does not visit such declarations and does not mark them to be preserved in the binary even if not public and used.

Resolves rdar://127903662
@artemcm artemcm requested a review from nkcsgexi May 16, 2024 20:06
@artemcm artemcm requested a review from a team as a code owner May 16, 2024 20:06
@artemcm
Copy link
Contributor Author

artemcm commented May 16, 2024

@swift-ci test

@artemcm artemcm added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels May 16, 2024
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.

Good catch!

@artemcm artemcm merged commit f320935 into swiftlang:release/6.0 May 17, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 6.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants