Skip to content

[5.9 πŸ’][Compile Time Constant Extraction] Map types with archetypes out of context, before mangling them for printing. #67696

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

artemcm
Copy link
Contributor

@artemcm artemcm commented Aug 3, 2023

Cherry-pick of #67692

Matching logic in the ASTPrinter. Otherwise we attempt to mangle types with archetypes in them, which cannot be done, and causes the compiler to crash.

––– CCC Information –––
β€’ Train: Swift 5.9
β€’ Explanation: We have recently made late changes to compile-time metadata extraction from the AST in the compiler, in order to gather additional info about relevant conformances. One such addition is collecting mangled names of conformances’ properties and compile-time-known type values. Extracting mangled type names of such types has an edge case that the code did not cover, specifically mangling types which contain archetypes (generic type parameters). Upon encountering such types and trying to mangle them, the compiler, unfortunately, crashes during extraction. Earlier we attempted to bypass this by removing mangling of properties altogether, but this was not sufficient to address the overall issue. This change is the general fix which maps archetype-containing types out of their generic context, mapping them to the interface type, before attempting mangling. This is something the code should have been doing all along, as mangling archetypes is impossible.
β€’ Scope of Issue: User code with nominal types which conform to the extracted protocols and have properties whose type contains a generic parameter or whose properties are initialized with a type value which is a generic parameter will crash the compiler.
β€’ Origination: Recent changes to extraction code to augment it with additional metadata.
β€’ Risk: Small. This change causes types which are impossible to mangle to map to their interface type before mangling, removing an otherwise-always-crashing code-path.
β€’ main Pull Request URL: #67692
β€’ Reviewed By: @slavapestov
β€’ Automated Testing: Automated test added to the compiler test suite.

Resolves rdar://113039215

…ontext, before mangling them for printing.

Matching logic in the ASTPrinter. Otherwise we attempt to mangle types with archetypes in them, which cannot be done, and causes the compiler to crash.

Resolves rdar://113039215
@artemcm artemcm added πŸ’ release cherry pick Flag: Release branch cherry picks swift 5.9 labels Aug 3, 2023
@artemcm artemcm requested a review from a team as a code owner August 3, 2023 01:12
@artemcm
Copy link
Contributor Author

artemcm commented Aug 3, 2023

@swift-ci test

@artemcm
Copy link
Contributor Author

artemcm commented Aug 3, 2023

@swift-ci test Windows platform

3 similar comments
@artemcm
Copy link
Contributor Author

artemcm commented Aug 3, 2023

@swift-ci test Windows platform

@artemcm
Copy link
Contributor Author

artemcm commented Aug 3, 2023

@swift-ci test Windows platform

@artemcm
Copy link
Contributor Author

artemcm commented Aug 3, 2023

@swift-ci test Windows platform

@artemcm artemcm merged commit 627525c into swiftlang:release/5.9 Aug 3, 2023
@artemcm artemcm deleted the 59ConstExtractPrintTypesOutOfContext branch August 3, 2023 21:58
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 5.9
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants