@@ -980,6 +980,42 @@ SelfBounds swift::getSelfBoundsFromWhereClause(
980980 SelfBoundsFromWhereClauseRequest{decl}, {});
981981}
982982
983+ SelfBounds SelfBoundsFromGenericSignatureRequest::evaluate (
984+ Evaluator &evaluator, const ExtensionDecl *extDecl) const {
985+ SelfBounds result;
986+ if (!extDecl->hasComputedGenericSignature ())
987+ return result;
988+
989+ ASTContext &ctx = extDecl->getASTContext ();
990+ auto selfType = extDecl->getSelfInterfaceType ();
991+ for (const auto &req : extDecl->getGenericRequirements ()) {
992+ auto kind = req.getKind ();
993+ if (kind != RequirementKind::Conformance &&
994+ kind != RequirementKind::Superclass)
995+ continue ;
996+ // The left-hand side of the type constraint must be 'Self'.
997+ bool isSelfLHS = selfType->isEqual (req.getFirstType ());
998+ if (!isSelfLHS)
999+ continue ;
1000+
1001+ auto rhsDecls = directReferencesForType (req.getSecondType ());
1002+ SmallVector<ModuleDecl *, 2 > modulesFound;
1003+ auto rhsNominals = resolveTypeDeclsToNominal (
1004+ evaluator, ctx, rhsDecls, modulesFound, result.anyObject );
1005+ result.decls .insert (result.decls .end (), rhsNominals.begin (),
1006+ rhsNominals.end ());
1007+ }
1008+
1009+ return result;
1010+ }
1011+
1012+ SelfBounds
1013+ swift::getSelfBoundsFromGenericSignature (const ExtensionDecl *extDecl) {
1014+ auto &ctx = extDecl->getASTContext ();
1015+ return evaluateOrDefault (ctx.evaluator ,
1016+ SelfBoundsFromGenericSignatureRequest{extDecl}, {});
1017+ }
1018+
9831019TinyPtrVector<TypeDecl *>
9841020TypeDeclsFromWhereClauseRequest::evaluate (Evaluator &evaluator,
9851021 ExtensionDecl *ext) const {
0 commit comments