File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
lib/AST/RequirementMachine Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -136,17 +136,30 @@ static std::optional<int> shortlexCompare(const Symbol *lhsBegin,
136
136
RewriteContext &ctx) {
137
137
// First, compare the number of name and pack element symbols.
138
138
unsigned lhsNameCount = 0 ;
139
+ unsigned lhsPackElementCount = 0 ;
139
140
for (auto *iter = lhsBegin; iter != lhsEnd; ++iter) {
140
141
if (iter->getKind () == Symbol::Kind::Name)
141
142
++lhsNameCount;
143
+
144
+ if (iter->getKind () == Symbol::Kind::PackElement)
145
+ ++lhsPackElementCount;
142
146
}
143
147
144
148
unsigned rhsNameCount = 0 ;
149
+ unsigned rhsPackElementCount = 0 ;
145
150
for (auto *iter = rhsBegin; iter != rhsEnd; ++iter) {
146
151
if (iter->getKind () == Symbol::Kind::Name)
147
152
++rhsNameCount;
153
+
154
+ if (iter->getKind () == Symbol::Kind::PackElement)
155
+ ++rhsPackElementCount;
148
156
}
149
157
158
+ // A term with more pack element symbols orders after a term with
159
+ // fewer pack element symbols.
160
+ if (lhsPackElementCount != rhsPackElementCount)
161
+ return lhsPackElementCount > rhsPackElementCount ? 1 : -1 ;
162
+
150
163
// A term with more name symbols orders after a term with fewer name symbols.
151
164
if (lhsNameCount != rhsNameCount)
152
165
return lhsNameCount > rhsNameCount ? 1 : -1 ;
You can’t perform that action at this time.
0 commit comments