@@ -33,6 +33,11 @@ class DeclExportabilityVisitor
3333 DeclExportabilityVisitor (){};
3434
3535 bool visit (const Decl *D) {
36+ // Declarations nested in fragile functions are exported.
37+ if (D->getDeclContext ()->getFragileFunctionKind ().kind !=
38+ FragileFunctionKind::None)
39+ return true ;
40+
3641 if (auto value = dyn_cast<ValueDecl>(D)) {
3742 // A decl is exportable if it has a public access level.
3843 auto accessScope =
@@ -50,20 +55,6 @@ class DeclExportabilityVisitor
5055 bool visitDecl (const Decl *D) = delete;
5156 bool visitValueDecl (const ValueDecl *valueDecl) = delete;
5257
53- bool visitAbstractFunctionDecl (const AbstractFunctionDecl *afd) {
54- // If this function is nested within another function that is exportable to
55- // clients then it is also exportable.
56- auto dc = afd->getDeclContext ();
57- do {
58- if (auto parent = dyn_cast<AbstractFunctionDecl>(dc)) {
59- if (DeclExportabilityVisitor ().visit (parent))
60- return true ;
61- }
62- } while ((dc = dc->getParent ()));
63-
64- return false ;
65- }
66-
6758 bool visitExtensionDecl (const ExtensionDecl *ext) {
6859 // Extensions must extend exportable types to be exportable.
6960 auto nominalType = ext->getExtendedNominal ();
@@ -149,6 +140,7 @@ class DeclExportabilityVisitor
149140 DEFAULT_TO_ACCESS_LEVEL (TypeAlias);
150141 DEFAULT_TO_ACCESS_LEVEL (AssociatedType);
151142 DEFAULT_TO_ACCESS_LEVEL (AbstractStorage);
143+ DEFAULT_TO_ACCESS_LEVEL (AbstractFunction);
152144 DEFAULT_TO_ACCESS_LEVEL (Macro);
153145 DEFAULT_TO_ACCESS_LEVEL (EnumElement);
154146
0 commit comments