-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Variadic Generics] Always use PackType
as the substitution for type parameter packs.
#64166
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
This simplifies the representation and allows clients to handle fewer cases. It also removes an ambiguity in the representation which could lead us to have two canonical types for the same type. This is definitely not working yet, but I'm not making progress on it quickly enough to unblock what we need to unblock; it'll have to be fixed in parallel.
…d pack element environments. This allows the constraint system to ensure that for a given pack expansion locator, the given shape class is always the same when requesting the element environment. If the shape class differs, it means there's a same-shape requirement failure, which will be diagnosed via the ShapeOf constraint simplification.
The rewrite rules are not quite right yet for same-element requirements, so let's ban them for now.
…etonPackExpansion, and update variadic generics SILGen tests for the representation change.
if (!gp->isParameterPack()) | ||
return archetype; | ||
|
||
return PackType::getSingletonPackExpansion(archetype); |
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.
@slavapestov I tried changing this to:
return SubstitutionMap::get(
nominal->getGenericSignatureOfContext(),
genericEnv->getForwardingSubstitutionMap());
but it still crashed when building the standard library. I didn't spend much time figuring out why because I wanted to finish the PackType
representation change, but I can come back to it.
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.
Heh, no worries
@swift-ci please smoke test |
@swift-ci please smoke test |
@@ -920,6 +920,10 @@ static Type applyGenericArguments(Type type, TypeResolution resolution, | |||
auto arg = found->rhs; | |||
if (auto *expansionType = arg->getAs<PackExpansionType>()) | |||
arg = expansionType->getPatternType(); | |||
|
|||
if (arg->isParameterPack()) |
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.
PackMatcher should be refactored to do this. Right now it unwraps one element packs, and here we re-wrap them
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.
Ah, I'll fix that, thanks!
Canonicalize the representation of type parameter pack substitutions as
PackType
, instead of sometimes usingPackType
and sometimes usingPackArchetypeType
.Subsumes #63908