mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Perform component-wise substitution of pack expansions immediately.
Substitution of a pack expansion type may now produce a pack type. We immediately expand that pack when transforming a tuple, a function parameter, or a pack. I had to duplicate the component-wise transformation logic in the simplifyType transform, which I'm not pleased about, but a little code duplication seemed a lot better than trying to unify the code in two very different places. I think we're very close to being able to assert that pack expansion shapes are either pack archetypes or pack parameters; unfortunately, the pack matchers intentionally produce expansions of packs, and I didn't want to add that to an already-large patch.
This commit is contained in:
@@ -449,15 +449,15 @@ PackType *PackType::get(const ASTContext &C,
|
||||
auto arg = args[i];
|
||||
|
||||
if (params[i]->isParameterPack()) {
|
||||
wrappedArgs.push_back(PackExpansionType::get(
|
||||
arg, arg->getReducedShape()));
|
||||
auto argPackElements = arg->castTo<PackType>()->getElementTypes();
|
||||
wrappedArgs.append(argPackElements.begin(), argPackElements.end());
|
||||
continue;
|
||||
}
|
||||
|
||||
wrappedArgs.push_back(arg);
|
||||
}
|
||||
|
||||
return get(C, wrappedArgs)->flattenPackTypes();
|
||||
return get(C, wrappedArgs);
|
||||
}
|
||||
|
||||
PackType *PackType::getSingletonPackExpansion(Type param) {
|
||||
|
||||
Reference in New Issue
Block a user