File tree Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Expand file tree Collapse file tree 2 files changed +6
-18
lines changed Original file line number Diff line number Diff line change @@ -782,10 +782,6 @@ int swift::compareDependentTypes(Type type1, Type type2) {
782
782
// Fast-path check for equality.
783
783
if (type1->isEqual (type2)) return 0 ;
784
784
785
- // Packs are always ordered after scalar type parameters.
786
- if (type1->isParameterPack () != type2->isParameterPack ())
787
- return type2->isParameterPack () ? -1 : +1 ;
788
-
789
785
// Ordering is as follows:
790
786
// - Generic params
791
787
auto gp1 = type1->getAs <GenericTypeParamType>();
@@ -940,7 +936,12 @@ void GenericSignature::verify(ArrayRef<Requirement> reqts) const {
940
936
llvm::errs () << " \n " ;
941
937
dumpAndAbort ();
942
938
}
943
- if (compareDependentTypes (firstType, secondType) >= 0 ) {
939
+ // FIXME: Same-element rewrite rules are of the form [element].T => U,
940
+ // which turns into a same-type requirement repeat U == each T. The
941
+ // pack element must always be on the left side of the rule, so type
942
+ // parameters can appear out of order in the final same-type requirement.
943
+ if (firstType->isParameterPack () == secondType->isParameterPack () &&
944
+ compareDependentTypes (firstType, secondType) >= 0 ) {
944
945
llvm::errs () << " Out-of-order type parameters: " ;
945
946
reqt.dump (llvm::errs ());
946
947
llvm::errs () << " \n " ;
Original file line number Diff line number Diff line change @@ -136,30 +136,17 @@ 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 ;
140
139
for (auto *iter = lhsBegin; iter != lhsEnd; ++iter) {
141
140
if (iter->getKind () == Symbol::Kind::Name)
142
141
++lhsNameCount;
143
-
144
- if (iter->getKind () == Symbol::Kind::PackElement)
145
- ++lhsPackElementCount;
146
142
}
147
143
148
144
unsigned rhsNameCount = 0 ;
149
- unsigned rhsPackElementCount = 0 ;
150
145
for (auto *iter = rhsBegin; iter != rhsEnd; ++iter) {
151
146
if (iter->getKind () == Symbol::Kind::Name)
152
147
++rhsNameCount;
153
-
154
- if (iter->getKind () == Symbol::Kind::PackElement)
155
- ++rhsPackElementCount;
156
148
}
157
149
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
-
163
150
// A term with more name symbols orders after a term with fewer name symbols.
164
151
if (lhsNameCount != rhsNameCount)
165
152
return lhsNameCount > rhsNameCount ? 1 : -1 ;
You can’t perform that action at this time.
0 commit comments