@@ -6888,14 +6888,6 @@ namespace {
6888
6888
6889
6889
} // end anonymous namespace
6890
6890
6891
- static int compareSameTypeComponents (const SameTypeComponentRef *lhsPtr,
6892
- const SameTypeComponentRef *rhsPtr){
6893
- Type lhsType = lhsPtr->first ->derivedSameTypeComponents [lhsPtr->second ].type ;
6894
- Type rhsType = rhsPtr->first ->derivedSameTypeComponents [rhsPtr->second ].type ;
6895
-
6896
- return compareDependentTypes (lhsType, rhsType);
6897
- }
6898
-
6899
6891
void GenericSignatureBuilder::enumerateRequirements (
6900
6892
TypeArrayView<GenericTypeParamType> genericParams,
6901
6893
llvm::function_ref<
@@ -6914,10 +6906,6 @@ void GenericSignatureBuilder::enumerateRequirements(
6914
6906
subjects.push_back ({&equivClass, i});
6915
6907
}
6916
6908
6917
- // Sort the subject types in canonical order.
6918
- llvm::array_pod_sort (subjects.begin (), subjects.end (),
6919
- compareSameTypeComponents);
6920
-
6921
6909
for (const auto &subject : subjects) {
6922
6910
// Dig out the subject type and its corresponding component.
6923
6911
auto equivClass = subject.first ;
@@ -7151,6 +7139,15 @@ static void collectRequirements(GenericSignatureBuilder &builder,
7151
7139
7152
7140
requirements.push_back (Requirement (kind, depTy, repTy));
7153
7141
});
7142
+
7143
+ // Sort the subject types in canonical order. This needs to be a stable sort
7144
+ // so that the relative order of requirements that have the same subject type
7145
+ // is preserved.
7146
+ std::stable_sort (requirements.begin (), requirements.end (),
7147
+ [](const Requirement &lhs, const Requirement &rhs) {
7148
+ return compareDependentTypes (lhs.getFirstType (),
7149
+ rhs.getFirstType ()) < 0 ;
7150
+ });
7154
7151
}
7155
7152
7156
7153
GenericSignature GenericSignatureBuilder::computeGenericSignature (
0 commit comments