-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[runtime] Handle same-type constraints when resolving generic params #25984
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
I have a bunch of tests already but what did I miss? What classes of test did I miss? |
No functionality change.
Generic parameters for a context are normally classified as "key", meaning they have actual metadata provided at runtime, or non-key, meaning they're derivable from somewhere else. However, a nested context or constrained extension can take what would be a "key" parameter in a parent context and make it non-key in a child context. This messes with the mapping between the (depth, index) representation of generic parameters and the flat list of generic arguments. Fix this by (1) consistently substituting out extension contexts with the contexts of the extended types, and (2) using the most nested context to decide which parameters are key, instead of the context a parameter was originally introduced in. Note that (1) may have problems if/when extensions start introducing their /own/ generic parameters. For now I tried to be consistent with what was there. rdar://problem/52364601
@swift-ci Please test |
Build failed |
Build failed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great
@swift-ci Please test Linux |
Build failed |
@swift-ci Please test Linux |
I'm going to merge this as is and then test type reconstruction separately in a follow-up change (as pointed out by Slava). |
[runtime] Handle same-type constraints when resolving generic params rdar://problem/52364601 (cherry picked from commit 659c497)
Generic parameters for a context are normally classified as "key", meaning they have actual metadata provided at runtime, or non-key, meaning they're derivable from somewhere else. However, a nested context or constrained extension can take what would be a "key" parameter in a parent context and make it non-key in a child context. This messes with the mapping between the (depth, index) representation of generic parameters and the flat list of generic arguments. Fix this by (1) consistently substituting out extension contexts with the contexts of the extended types, and (2)
checking if a same-type constraint was (2a) newly applied in a particular context, and (2b) constrains a parent's generic parameterusing the most nested context to decide which parameters are key, instead of the context a parameter was originally introduced in.Note that this may have problems if/when extensions start introducing their own generic parameters (*cough* #25263 *cough*). For now I tried to be consistent with what was there.
rdar://problem/52364601