@@ -3674,23 +3674,13 @@ void GenericSignatureBuilder::Implementation::removeRewriteTreeRedundancies(
3674
3674
}
3675
3675
}
3676
3676
3677
- bool GenericSignatureBuilder::addSameTypeRewriteRule (
3678
- EquivalenceClass *equivClass,
3679
- PotentialArchetype *otherPA){
3680
- // Simplify both sides in the hope of uncovering a common path.
3681
- Type simplifiedType1 = equivClass->getAnchor (*this , { });
3682
-
3683
- Type simplifiedType2;
3684
- if (auto otherEquivClass = otherPA->getEquivalenceClassIfPresent ())
3685
- simplifiedType2 = otherEquivClass->getAnchor (*this , { });
3686
- else
3687
- simplifiedType2 = getCanonicalTypeParameter (otherPA->getDependentType ({ }));
3688
-
3677
+ bool GenericSignatureBuilder::addSameTypeRewriteRule (CanType type1,
3678
+ CanType type2) {
3689
3679
// We already effectively have this rewrite rule.
3690
- if (simplifiedType1-> isEqual (simplifiedType2) ) return false ;
3680
+ if (type1 == type2 ) return false ;
3691
3681
3692
- auto path1 = RewritePath::createPath (simplifiedType1 );
3693
- auto path2 = RewritePath::createPath (simplifiedType2 );
3682
+ auto path1 = RewritePath::createPath (type1 );
3683
+ auto path2 = RewritePath::createPath (type2 );
3694
3684
3695
3685
// Look for a common prefix. When we have one, form a rewrite rule using
3696
3686
// relative paths.
@@ -3719,9 +3709,9 @@ bool GenericSignatureBuilder::addSameTypeRewriteRule(
3719
3709
// Otherwise, form a rewrite rule with absolute paths.
3720
3710
3721
3711
// Find the better path and make sure it's in path2.
3722
- if (compareDependentTypes (simplifiedType1, simplifiedType2 ) < 0 ) {
3712
+ if (compareDependentTypes (type1, type2 ) < 0 ) {
3723
3713
std::swap (path1, path2);
3724
- std::swap (simplifiedType1, simplifiedType2 );
3714
+ std::swap (type1, type2 );
3725
3715
}
3726
3716
3727
3717
// Add the rewrite rule.
@@ -4872,10 +4862,6 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
4872
4862
: getCanonicalTypeParameter (T2->getDependentType ({ })))
4873
4863
->getCanonicalType ();
4874
4864
4875
- // Add a rewrite rule to map T2 down to the anchor.
4876
- if (addSameTypeRewriteRule (equivClass, T2))
4877
- ++Impl->RewriteGeneration ;
4878
-
4879
4865
// Merge the equivalence classes.
4880
4866
equivClass->modified (*this );
4881
4867
auto equivClass1Members = equivClass->members ;
@@ -4917,6 +4903,10 @@ GenericSignatureBuilder::addSameTypeRequirementBetweenArchetypes(
4917
4903
}
4918
4904
}
4919
4905
4906
+ // Add a rewrite rule to map the anchor of T2 down to the anchor of T1.
4907
+ if (addSameTypeRewriteRule (anchor2, anchor1))
4908
+ ++Impl->RewriteGeneration ;
4909
+
4920
4910
// Same-type-to-concrete requirements.
4921
4911
bool t1IsConcrete = !equivClass->concreteType .isNull ();
4922
4912
bool t2IsConcrete = equivClass2 && !equivClass2->concreteType .isNull ();
0 commit comments