-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Place Opened Archetypes in their Proper Generic Contexts #41677
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
CodaFi
merged 7 commits into
swiftlang:main
from
CodaFi:substitutions-available-upon-request
Mar 8, 2022
Merged
Place Opened Archetypes in their Proper Generic Contexts #41677
CodaFi
merged 7 commits into
swiftlang:main
from
CodaFi:substitutions-available-upon-request
Mar 8, 2022
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
@swift-ci test |
3b34b0a
to
1fe38b0
Compare
slavapestov
reviewed
Mar 7, 2022
@@ -4421,6 +4422,11 @@ CanTypeWrapper<OpenedArchetypeType> OpenedArchetypeType::getNew( | |||
GenericEnvironment *environment, Type interfaceType, | |||
ArrayRef<ProtocolDecl *> conformsTo, Type superclass, | |||
LayoutConstraint layout) { | |||
// FIXME: It'd be great if all of our callers could submit interface types. |
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.
Callers should be able to provide a substitution map to map generic parameters to archetypes or type variables.
This ensures that opened archetypes always inherit any outer generic parameters from the context in which they reside. This matters because class bounds may bind generic parameters from these outer contexts, and without the outer context you can wind up with ill-formed generic environments like <τ_0_0, where τ_0_0 : C<T>, τ_0_0 : P> Where T is otherwise unbound because there is no entry for it among the generic parameters of the environment's associated generic signature.
…Composites The requirements are not always going to appear with superclass constraints last, so we still need to ensure that superclass bounds wind up at the head of the set of members.
1fe38b0
to
445c494
Compare
@swift-ci smoke test |
445c494
to
f694bf5
Compare
@swift-ci smoke 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.
Part 1 of a refactoring intended to ultimately support a more generic representation of opened archetypes for parameterized protocol types.
This does a massive amount of plumbing to ensure that the
DeclContext
corresponding to the actual usage of an existential being opened is provided to abstractions dealing with opened archetypes. This allows us to extract any outer generic parameters and prepend them to the archetype's generic signature. This ultimately means that theSelf
parameter of an opened archetype no longer corresponds totau_0_0
, but instead resides atgeneric context depth + 1
for most types. Protocol extensions are the exception as theSelf
type appears astau_0_0
in context anyways. Callers should use the newOpenedArchetypeType::getSelfInterfaceTypeFromContext
instead of constructing generic parameter types forSelf
.