@@ -724,10 +724,28 @@ StructuralRequirementsRequest::evaluate(Evaluator &evaluator,
724
724
725
725
auto selfTy = proto->getSelfInterfaceType ();
726
726
727
+ unsigned errorCount = errors.size ();
727
728
realizeInheritedRequirements (proto, selfTy,
728
729
/* inferRequirements=*/ false ,
729
730
result, errors);
730
731
732
+ if (errors.size () > errorCount) {
733
+ // Add requirements from inherited protocols, which are obtained via
734
+ // getDirectlyInheritedNominalTypeDecls(). Normally this duplicates
735
+ // the information found in the resolved types from the inheritance
736
+ // clause, except when type resolution fails and returns an ErrorType.
737
+ //
738
+ // For example, in 'protocol P: Q & Blah', where 'Blah' does not exist,
739
+ // the type 'Q & Blah' resolves to an ErrorType, while the simpler
740
+ // mechanism in getDirectlyInheritedNominalTypeDecls() still finds 'Q'.
741
+ for (auto *inheritedProto : proto->getInheritedProtocols ()) {
742
+ result.push_back ({
743
+ Requirement (RequirementKind::Conformance,
744
+ selfTy, inheritedProto->getDeclaredInterfaceType ()),
745
+ SourceLoc (), /* wasInferred=*/ false });
746
+ }
747
+ }
748
+
731
749
// Add requirements from the protocol's own 'where' clause.
732
750
WhereClauseOwner (proto).visitRequirements (TypeResolutionStage::Structural,
733
751
[&](const Requirement &req, RequirementRepr *reqRepr) {
0 commit comments