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