Skip to content

[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

Merged

Conversation

DougGregor
Copy link
Member

@DougGregor DougGregor commented Apr 28, 2017

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.

As an added bonus, flatten the storage of replacement types in SubstitutionMap. It was a DenseMap, now make it an array.

@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

if (known != subMap.end() && known->second)
return known->second;

// The generic parameter may have been made concrete by the generic signature,
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah.

Copy link
Member Author

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.
@DougGregor DougGregor force-pushed the sub-map-concrete-generic-params branch from 441194c to 6ef76a9 Compare April 28, 2017 23:22
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@DougGregor
Copy link
Member Author

@swift-ci please clean smoke test Linux

1 similar comment
@DougGregor
Copy link
Member Author

@swift-ci please clean smoke test Linux

@DougGregor DougGregor merged commit ebd34ec into swiftlang:master Apr 29, 2017
@DougGregor DougGregor deleted the sub-map-concrete-generic-params branch April 29, 2017 00:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants