Skip to content
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

[6.0 🍒][Compile Time Constant Extraction] Query nominal type conformances to get at the protocols, instead of getAllProtocols. #74713

Merged

Conversation

artemcm
Copy link
Contributor

@artemcm artemcm commented Jun 25, 2024

Cherry-pick of #74698

Explanation: As it stands, for extension macros which add protocol conformances, the list of protocols specified on the macro's 'conformances:' parameter gets added in its entirety to the list of a nominal type's protocols in 'ConformanceLookupTable::addMacroGeneratedProtocols'. Whereas the macro itself, may only add some of the specified conformances. This means that getAllProtocols may contain a super-set of protocols captured in getAllConformances, some of which may not actually be generated by the macro.

This change narrowly fixes ConstExtract to query actual generated conformances. Though, potentially we should make 'ConformanceLookupTable::addMacroGeneratedProtocols' behave in a way that reflects the protocols the macro actually adds the conformances to, instead of the ones it may add conformances to.

Risk: Low. This change affects the compile-time metadata extraction code-path and only affects the produced set of conformances by using a stricter way to gather them than before.

Testing: Automated test added to the compiler test suite.

Resolves rdar:https://130316531

… get at the protocols, instead of `getAllProtocols`.

As it stands, for extension macros which add protocol conformances, the list of protocols specified on the macro's 'conformances:' parameter gets added in its entirety to the list of a nominal type's protocols in 'ConformanceLookupTable::addMacroGeneratedProtocols'. Whereas the macro itself, may only add *some* of the specified conformances. This means that `getAllProtocols` may contain a super-set of protocols captured in `getAllConformances`, some of which may not actually be generated by the macro.

This change narrowly fixes ConstExtract to query actual generated conformances. Though, potentially we should make 'ConformanceLookupTable::addMacroGeneratedProtocols' behave in a way that reflects the protocols the macro actually adds the conformances to, instead of the ones it may add conformances to.

Resolves rdar:https://130316531
@artemcm artemcm added 🍒 release cherry pick Flag: Release branch cherry picks swift 6.0 labels Jun 25, 2024
@artemcm artemcm requested a review from nkcsgexi June 25, 2024 22:02
@artemcm artemcm requested a review from a team as a code owner June 25, 2024 22:02
@artemcm
Copy link
Contributor Author

artemcm commented Jun 25, 2024

@swift-ci test

@artemcm artemcm merged commit e212e6e into swiftlang:release/6.0 Jun 27, 2024
5 checks passed
@artemcm artemcm deleted the 60ConstExtractConformanceExtractionFix branch June 27, 2024 16:56
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.

None yet

2 participants