@@ -58,6 +58,7 @@ class RequirementRepr {
5858 SourceLoc SeparatorLoc;
5959 RequirementReprKind Kind : 2 ;
6060 bool Invalid : 1 ;
61+ bool IsExpansionPattern : 1 ;
6162 TypeRepr *FirstType;
6263
6364 // / The second element represents the right-hand side of the constraint.
@@ -72,13 +73,17 @@ class RequirementRepr {
7273 StringRef AsWrittenString;
7374
7475 RequirementRepr (SourceLoc SeparatorLoc, RequirementReprKind Kind,
75- TypeRepr *FirstType, TypeRepr *SecondType)
76+ TypeRepr *FirstType, TypeRepr *SecondType,
77+ bool IsExpansionPattern)
7678 : SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false ),
79+ IsExpansionPattern (IsExpansionPattern),
7780 FirstType(FirstType), SecondType(SecondType) { }
7881
7982 RequirementRepr (SourceLoc SeparatorLoc, RequirementReprKind Kind,
80- TypeRepr *FirstType, LayoutConstraintLoc SecondLayout)
83+ TypeRepr *FirstType, LayoutConstraintLoc SecondLayout,
84+ bool IsExpansionPattern)
8185 : SeparatorLoc(SeparatorLoc), Kind(Kind), Invalid(false ),
86+ IsExpansionPattern(IsExpansionPattern),
8287 FirstType(FirstType), SecondLayout(SecondLayout) { }
8388
8489public:
@@ -92,8 +97,10 @@ class RequirementRepr {
9297 // / subject must conform, or superclass from which the subject must inherit.
9398 static RequirementRepr getTypeConstraint (TypeRepr *Subject,
9499 SourceLoc ColonLoc,
95- TypeRepr *Constraint) {
96- return { ColonLoc, RequirementReprKind::TypeConstraint, Subject, Constraint };
100+ TypeRepr *Constraint,
101+ bool IsExpansionPattern) {
102+ return { ColonLoc, RequirementReprKind::TypeConstraint, Subject, Constraint,
103+ IsExpansionPattern };
97104 }
98105
99106 // / Construct a new same-type requirement.
@@ -104,8 +111,10 @@ class RequirementRepr {
104111 // / \param SecondType The second type.
105112 static RequirementRepr getSameType (TypeRepr *FirstType,
106113 SourceLoc EqualLoc,
107- TypeRepr *SecondType) {
108- return { EqualLoc, RequirementReprKind::SameType, FirstType, SecondType };
114+ TypeRepr *SecondType,
115+ bool IsExpansionPattern) {
116+ return { EqualLoc, RequirementReprKind::SameType, FirstType, SecondType,
117+ IsExpansionPattern };
109118 }
110119
111120 // / Construct a new layout-constraint requirement.
@@ -118,9 +127,10 @@ class RequirementRepr {
118127 // / subject must conform.
119128 static RequirementRepr getLayoutConstraint (TypeRepr *Subject,
120129 SourceLoc ColonLoc,
121- LayoutConstraintLoc Layout) {
130+ LayoutConstraintLoc Layout,
131+ bool IsExpansionPattern) {
122132 return {ColonLoc, RequirementReprKind::LayoutConstraint, Subject,
123- Layout};
133+ Layout, IsExpansionPattern };
124134 }
125135
126136 // / Determine the kind of requirement
@@ -129,6 +139,12 @@ class RequirementRepr {
129139 // / Determine whether this requirement is invalid.
130140 bool isInvalid () const { return Invalid; }
131141
142+ // / Whether this requirement repr is the pattern of a requirement
143+ // / expansion, e.g. `repeat G<each T> == (each U).A`
144+ bool isExpansionPattern () const {
145+ return IsExpansionPattern;
146+ }
147+
132148 // / Mark this requirement invalid.
133149 void setInvalid () { Invalid = true ; }
134150
0 commit comments