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:
John McCall
2023-03-25 18:46:29 -04:00
parent d16fed6e9a
commit c041d1061a
9 changed files with 398 additions and 386 deletions

View File

@@ -3257,6 +3257,12 @@ CanPackExpansionType::get(CanType patternType, CanType countType) {
}
PackExpansionType *PackExpansionType::get(Type patternType, Type countType) {
assert(!patternType->is<PackExpansionType>());
assert(!countType->is<PackExpansionType>());
// FIXME: stop doing this deliberately in PackExpansionMatcher
//assert(!patternType->is<PackType>());
//assert(!countType->is<PackType>());
auto properties = patternType->getRecursiveProperties();
properties |= countType->getRecursiveProperties();