@@ -831,8 +831,7 @@ int swift::compareAssociatedTypes(AssociatedTypeDecl *assocType1,
831
831
return 0 ;
832
832
}
833
833
834
- // / Canonical ordering for type parameters.
835
- int swift::compareDependentTypes (Type type1, Type type2) {
834
+ static int compareDependentTypesRec (Type type1, Type type2) {
836
835
// Fast-path check for equality.
837
836
if (type1->isEqual (type2)) return 0 ;
838
837
@@ -853,7 +852,7 @@ int swift::compareDependentTypes(Type type1, Type type2) {
853
852
854
853
// - by base, so t_0_n.`P.T` < t_1_m.`P.T`
855
854
if (int compareBases =
856
- compareDependentTypes (depMemTy1->getBase (), depMemTy2->getBase ()))
855
+ compareDependentTypesRec (depMemTy1->getBase (), depMemTy2->getBase ()))
857
856
return compareBases;
858
857
859
858
// - by name, so t_n_m.`P.T` < t_n_m.`P.U`
@@ -869,6 +868,17 @@ int swift::compareDependentTypes(Type type1, Type type2) {
869
868
return 0 ;
870
869
}
871
870
871
+ // / Canonical ordering for type parameters.
872
+ int swift::compareDependentTypes (Type type1, Type type2) {
873
+ auto *root1 = type1->getRootGenericParam ();
874
+ auto *root2 = type2->getRootGenericParam ();
875
+ if (root1->getWeight () != root2->getWeight ()) {
876
+ return root2->getWeight () ? -1 : +1 ;
877
+ }
878
+
879
+ return compareDependentTypesRec (type1, type2);
880
+ }
881
+
872
882
#pragma mark Generic signature verification
873
883
874
884
void GenericSignature::verify () const {
0 commit comments