-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Substitution Map] Handle substitutions of generic parameters made concrete #9106
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
[Substitution Map] Handle substitutions of generic parameters made concrete #9106
Conversation
@swift-ci please smoke test and merge |
lib/AST/SubstitutionMap.cpp
Outdated
if (known != subMap.end() && known->second) | ||
return known->second; | ||
|
||
// The generic parameter may have been made concrete by the generic signature, |
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.
Why don't we just put the concrete type in the replacement map when we build the signature?
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.
That would fit better with a flat array of replacement types, I guess.
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.
Yeah.
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.
We have to do it lazily because the concrete types can end up referring to other generic type parameters. Which also means I need to deal with the recursion in ill-formed programs (hence the failures).
…ncrete. If SubstitutionMap is asked to form a substitution for a generic parameter that has been made concrete by the generic signature, substitute into the concrete type. This allows us to better deal with non-canonical types.
The replacement types in a SubstitutionMap correspond with the generic parameters of its generic signature, so replace the DenseMap storage with a flat array of Types, one element for each generic parameter.
441194c
to
6ef76a9
Compare
@swift-ci please smoke test and merge |
1 similar comment
@swift-ci please smoke test and merge |
@swift-ci please clean smoke test Linux |
1 similar comment
@swift-ci please clean smoke test Linux |
If
SubstitutionMap
is asked to form a substitution for a genericparameter that has been made concrete by the generic signature,
substitute into the concrete type. This allows us to better deal with
non-canonical types.
As an added bonus, flatten the storage of replacement types in
SubstitutionMap
. It was aDenseMap
, now make it an array.