Add Sugar for Variadics

We used to represent the interface type of variadic parameters directly
with ArraySliceType. This was awfully convenient for the constraint
solver since it could just canonicalize and open [T] to Array<$T>
wherever it saw a variadic parameter. However, this both destroys the
sugaring of T... and locks the representation to Array<T>. In the
interest of generalizing this in the future, introduce
VariadicSequenceType. For now, it canonicalizes to Array<T> just like
the old representation. But, as you can guess, this is a new staging
point for teaching the solver how to munge variadic generic type bindings.

rdar://81628287
This commit is contained in:
Robert Widmann
2021-08-06 12:25:45 -07:00
parent 9f71ee1b0a
commit 592e90af9b
17 changed files with 98 additions and 16 deletions

View File

@@ -5901,6 +5901,18 @@ public:
return OptionalType::get(baseTy.get());
}
Expected<Type> deserializeVariadicSequenceType(ArrayRef<uint64_t> scratch,
StringRef blobData) {
TypeID baseID;
decls_block::VariadicSequenceTypeLayout::readRecord(scratch, baseID);
auto baseTy = MF.getTypeChecked(baseID);
if (!baseTy)
return baseTy.takeError();
return VariadicSequenceType::get(baseTy.get());
}
Expected<Type> deserializeUnboundGenericType(ArrayRef<uint64_t> scratch,
StringRef blobData) {
DeclID genericID;
@@ -6024,6 +6036,7 @@ Expected<Type> TypeDeserializer::getTypeCheckedImpl() {
CASE(ArraySlice)
CASE(Dictionary)
CASE(Optional)
CASE(VariadicSequence)
CASE(UnboundGeneric)
CASE(Error)