@@ -219,7 +219,7 @@ class GeneratingConformances {
219219
220220 void verifyGeneratingConformanceEquations () const ;
221221
222- void computeGeneratingConformances ();
222+ void computeGeneratingConformances (bool firstPass );
223223
224224 void verifyGeneratingConformances () const ;
225225
@@ -799,10 +799,37 @@ void GeneratingConformances::verifyGeneratingConformanceEquations() const {
799799
800800// / Find a minimal set of generating conformances by marking all other
801801// / conformances redundant.
802- void GeneratingConformances::computeGeneratingConformances () {
802+ // /
803+ // / In the first pass, we only consider conformance requirements that are
804+ // / made redundant by concrete conformances.
805+ void GeneratingConformances::computeGeneratingConformances (
806+ bool firstPass) {
803807 for (unsigned ruleID : ConformanceRules) {
804808 const auto &paths = ConformancePaths[ruleID];
805809
810+ if (firstPass) {
811+ bool derivedViaConcrete = false ;
812+ for (const auto &path : paths) {
813+ if (path.empty ())
814+ break ;
815+
816+ if (System.getRule (path.back ()).getLHS ().back ().getKind () ==
817+ Symbol::Kind::ConcreteConformance) {
818+ derivedViaConcrete = true ;
819+ break ;
820+ }
821+ }
822+
823+ // If this rule doesn't involve concrete conformances it will be
824+ // considered in the second pass.
825+ if (!derivedViaConcrete)
826+ continue ;
827+ } else {
828+ // Ignore rules already determined to be redundant by the first pass.
829+ if (RedundantConformances.count (ruleID) > 0 )
830+ continue ;
831+ }
832+
806833 bool isProtocolRefinement = ProtocolRefinements.count (ruleID) > 0 ;
807834
808835 for (const auto &path : paths) {
@@ -893,7 +920,8 @@ void RewriteSystem::computeGeneratingConformances(
893920 }
894921
895922 builder.verifyGeneratingConformanceEquations ();
896- builder.computeGeneratingConformances ();
923+ builder.computeGeneratingConformances (/* firstPass=*/ true );
924+ builder.computeGeneratingConformances (/* firstPass=*/ false );
897925 builder.verifyGeneratingConformances ();
898926
899927 if (Debug.contains (DebugFlags::GeneratingConformances)) {
0 commit comments