@@ -33,6 +33,11 @@ class DeclExportabilityVisitor
33
33
DeclExportabilityVisitor (){};
34
34
35
35
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
+
36
41
if (auto value = dyn_cast<ValueDecl>(D)) {
37
42
// A decl is exportable if it has a public access level.
38
43
auto accessScope =
@@ -50,20 +55,6 @@ class DeclExportabilityVisitor
50
55
bool visitDecl (const Decl *D) = delete;
51
56
bool visitValueDecl (const ValueDecl *valueDecl) = delete;
52
57
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
-
67
58
bool visitExtensionDecl (const ExtensionDecl *ext) {
68
59
// Extensions must extend exportable types to be exportable.
69
60
auto nominalType = ext->getExtendedNominal ();
@@ -149,6 +140,7 @@ class DeclExportabilityVisitor
149
140
DEFAULT_TO_ACCESS_LEVEL (TypeAlias);
150
141
DEFAULT_TO_ACCESS_LEVEL (AssociatedType);
151
142
DEFAULT_TO_ACCESS_LEVEL (AbstractStorage);
143
+ DEFAULT_TO_ACCESS_LEVEL (AbstractFunction);
152
144
DEFAULT_TO_ACCESS_LEVEL (Macro);
153
145
DEFAULT_TO_ACCESS_LEVEL (EnumElement);
154
146
0 commit comments