@@ -124,7 +124,8 @@ class RecursiveTypeProperties {
124
124
HasTypeVariable = 0x01 ,
125
125
126
126
// / This type expression contains a context-dependent archetype, either a
127
- // / PrimaryArchetypeType or OpenedArchetypeType.
127
+ // / \c PrimaryArchetypeType, \c OpenedArchetypeType, or
128
+ // / \c SequenceArchetype.
128
129
HasArchetype = 0x02 ,
129
130
130
131
// / This type expression contains a GenericTypeParamType.
@@ -5683,6 +5684,50 @@ CanArchetypeType getParent() const {
5683
5684
}
5684
5685
END_CAN_TYPE_WRAPPER (NestedArchetypeType, ArchetypeType)
5685
5686
5687
+ // / An archetype that represents an opaque element of a type sequence in context.
5688
+ // /
5689
+ // / \code
5690
+ // / struct Foo<@_typeSequence Ts> { var xs: @_typeSequence Ts }
5691
+ // / func foo<@_typeSequence T>(_ xs: T...) where T: P { }
5692
+ // / \endcode
5693
+ class SequenceArchetypeType final
5694
+ : public ArchetypeType,
5695
+ private ArchetypeTrailingObjects<SequenceArchetypeType> {
5696
+ friend TrailingObjects;
5697
+ friend ArchetypeType;
5698
+
5699
+ GenericEnvironment *Environment;
5700
+
5701
+ public:
5702
+ // / getNew - Create a new sequence archetype with the given name.
5703
+ // /
5704
+ // / The ConformsTo array will be minimized then copied into the ASTContext
5705
+ // / by this routine.
5706
+ static CanTypeWrapper<SequenceArchetypeType>
5707
+ get (const ASTContext &Ctx, GenericEnvironment *GenericEnv,
5708
+ GenericTypeParamType *InterfaceType,
5709
+ SmallVectorImpl<ProtocolDecl *> &ConformsTo, Type Superclass,
5710
+ LayoutConstraint Layout);
5711
+
5712
+ // / Retrieve the generic environment in which this archetype resides.
5713
+ GenericEnvironment *getGenericEnvironment () const { return Environment; }
5714
+
5715
+ GenericTypeParamType *getInterfaceType () const {
5716
+ return cast<GenericTypeParamType>(InterfaceType.getPointer ());
5717
+ }
5718
+
5719
+ static bool classof (const TypeBase *T) {
5720
+ return T->getKind () == TypeKind::SequenceArchetype;
5721
+ }
5722
+
5723
+ private:
5724
+ SequenceArchetypeType (const ASTContext &Ctx, GenericEnvironment *GenericEnv,
5725
+ Type InterfaceType, ArrayRef<ProtocolDecl *> ConformsTo,
5726
+ Type Superclass, LayoutConstraint Layout);
5727
+ };
5728
+ BEGIN_CAN_TYPE_WRAPPER (SequenceArchetypeType, ArchetypeType)
5729
+ END_CAN_TYPE_WRAPPER(SequenceArchetypeType, ArchetypeType)
5730
+
5686
5731
template<typename Type>
5687
5732
const Type *ArchetypeType::getSubclassTrailingObjects() const {
5688
5733
if (auto contextTy = dyn_cast<PrimaryArchetypeType>(this )) {
@@ -5697,6 +5742,9 @@ const Type *ArchetypeType::getSubclassTrailingObjects() const {
5697
5742
if (auto childTy = dyn_cast<NestedArchetypeType>(this )) {
5698
5743
return childTy->getTrailingObjects <Type>();
5699
5744
}
5745
+ if (auto childTy = dyn_cast<SequenceArchetypeType>(this )) {
5746
+ return childTy->getTrailingObjects <Type>();
5747
+ }
5700
5748
llvm_unreachable (" unhandled ArchetypeType subclass?" );
5701
5749
}
5702
5750
0 commit comments