Skip to content

Commit ab0868c

Browse files
committed
AST: Introduce PackArchetypeType::getSingletonPackType()
1 parent 49bc191 commit ab0868c

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

include/swift/AST/Types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6054,6 +6054,8 @@ class PackArchetypeType final
60546054
return T->getKind() == TypeKind::PackArchetype;
60556055
}
60566056

6057+
CanTypeWrapper<PackType> getSingletonPackType();
6058+
60576059
private:
60586060
PackArchetypeType(const ASTContext &Ctx, GenericEnvironment *GenericEnv,
60596061
Type InterfaceType, ArrayRef<ProtocolDecl *> ConformsTo,

lib/AST/ParameterPack.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,4 +418,11 @@ PackType *PackType::get(const ASTContext &C,
418418
}
419419

420420
return get(C, wrappedArgs)->flattenPackTypes();
421-
}
421+
}
422+
423+
424+
CanPackType PackArchetypeType::getSingletonPackType() {
425+
SmallVector<Type, 1> types;
426+
types.push_back(PackExpansionType::get(this, getReducedShape()));
427+
return CanPackType(PackType::get(getASTContext(), types));
428+
}

lib/IRGen/GenType.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,15 +2215,12 @@ const TypeInfo *TypeConverter::convertType(CanType ty) {
22152215
case TypeKind::Pack:
22162216
return convertPackType(cast<PackType>(ty));
22172217
case TypeKind::PackArchetype: {
2218-
// FIXME: This is the wrong place for this kind of wrapping
2219-
SmallVector<Type> elts;
22202218
auto archetypeTy = cast<PackArchetypeType>(ty);
2221-
elts.push_back(PackExpansionType::get(archetypeTy,
2222-
archetypeTy->getReducedShape()));
2223-
return convertPackType(PackType::get(IGM.Context, elts));
2219+
return convertPackType(archetypeTy->getSingletonPackType());
22242220
}
22252221
case TypeKind::PackExpansion: {
2226-
// FIXME: This is the wrong place for this kind of wrapping
2222+
// FIXME: SIL shouldn't emit values with pack expansion type; they
2223+
// should always be wrapped in a PackType or be a bare PackArchetypeType
22272224
SmallVector<Type> elts;
22282225
elts.push_back(ty);
22292226
return convertPackType(PackType::get(IGM.Context, elts));

0 commit comments

Comments
 (0)