-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Introduce GenericEnvironment refactoring and kill AllArchetypes #4524
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
slavapestov
merged 13 commits into
swiftlang:master
from
slavapestov:generic-environment
Aug 29, 2016
Merged
Introduce GenericEnvironment refactoring and kill AllArchetypes #4524
slavapestov
merged 13 commits into
swiftlang:master
from
slavapestov:generic-environment
Aug 29, 2016
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b0b942b
to
c6f2a2e
Compare
@swift-ci Please smoke test |
A GenericEnvironment stores the mapping between GenericTypeParamTypes and context archetypes (or eventually, concrete types, once we allow extensions to constrain a generic parameter to a concrete type). The goals here are two-fold: - Eliminate the GenericTypeParamDecl::getArchetype() method, and always use mapTypeIntoContext() instead - Replace SILFunction::ContextGenericParams with a GenericEnvironment This patch adds the new data type as well as serializer and AST verifier support. but nothing else uses it yet. Note that GenericSignature::get() now asserts if there are no generic parameters, instead of returning null. This requires a few tweaks here and there.
…ontext() When we call the DeclContext variants of these, use the DeclContext's GenericEnvironment instead of GenericParamList. Also, these functions would take a resolver argument, but we always passed in nullptr, so just remove it now. The old GenericParamList-based versions are still there since they're called directly from SIL. They will go away once SILFunction::ContextGenericParams is replaced with a GenericEnvironment.
This patch is rather large, since it was hard to make this change incrementally, but most of the changes are mechanical. Now that we have a lighter-weight data structure in the AST for mapping interface types to archetypes and vice versa, use that in SIL instead of a GenericParamList. This means that when serializing a SILFunction body, we no longer need to serialize references to archetypes from other modules. Several methods used for forming substitutions can now be moved from GenericParamList to GenericEnvironment. Also, GenericParamList::cloneWithOuterParameters() and GenericParamList::getEmpty() can now go away, since they were only used when SILGen-ing witness thunks. Finally, when printing generic parameters with identical names, the SIL printer used to number them from highest depth to lowest, by walking generic parameter lists starting with the innermost one. Now, ambiguous generic parameters are numbered from lowest depth to highest, by walking the generic signature, which means test output in one of the SILGen tests has changed.
…,OutOf}Context() The last remaining use was in the SIL parser. Plumb through a GenericEnvironment. The code here really could use additional cleanup...
Now that SILFunctions store a GenericEnvironment instead of a GenericParamList, we can remove some unused flexibility.
Now that SILFunctions no longer reference a GenericParamList, we don't need to de-serialize cross-module references to archetypes anymore. This was the last remaining usage of AllArchetypes, so we can finally rip it out.
Instead of looking at GenericParam requirements, look at the generic signature.
…anges I've got a big overhaul of collectRequirements() coming shortly, so I'm not going to bother fixing this properly here.
The code here should not type check, because we're adding a requirement to an outer archetype. I'm working on some changes to ArchetypeBuilder that will make this kind of thing easier to catch.
c6f2a2e
to
97d0562
Compare
@swift-ci Please test |
1 similar comment
@swift-ci Please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds a new
GenericEnvironment
type, meant to store the mapping between interface types and archetypes.SILFunctions
have aGenericEnvironment
now, instead of aGenericParamList
. This considerably simplifies serialization of archetypes because we no longer have to worry about serializing references to archetypes from other modules.The
GenericEnvironment
replaces theAllArchetypes
list, and mostly replaces theArchetype
field ofAbstractTypeParamDecl
, however the latter still exists. I'm removing it in a separate PR, since this one is already getting rather huge.