Model Pack Types

A pack type looks a lot like a tuple in the surface language, except there
is no way for the user to spell a pack. Pack types are created by the solver
when it encounters an apply of a variadic generic function, as in

```
func print<T...>(_ xs: T...) {}
// Creates a pack type <String, Int, String>
print("Macs say Hello in", 42, " different languages")
```

Pack types substituted into the variadic generic arguments of a
PackExpansionType "trip" the pack expansion and cause it to produce a
new pack type with the pack expansion pattern applied.

```
typealias Foo<T...> = (T?...)
Foo<Int, String, Int> // Forces expansion to (Int?, String?, Int?)
```
This commit is contained in:
Robert Widmann
2021-12-16 00:25:34 -08:00
parent 99f6c3e9a3
commit 746aa1fb58
19 changed files with 275 additions and 1 deletions

View File

@@ -1695,7 +1695,11 @@ public:
return handleGenericNominalType(pattern.getType(), bgt,
pattern.getGenericSignatureOrNull());
}
CanType visitPackType(PackType *pack, AbstractionPattern pattern) {
llvm_unreachable("Unimplemented!");
}
CanType visitTupleType(TupleType *tuple, AbstractionPattern pattern) {
if (auto gp = handleTypeParameterInAbstractionPattern(pattern, tuple))
return gp;