@@ -3060,7 +3060,7 @@ bool AbstractStorageDecl::isResilient(ModuleDecl *M,
3060
3060
case ResilienceExpansion::Maximal:
3061
3061
if (M == getModuleContext ())
3062
3062
return false ;
3063
- // Non-resilient if bypass optimization in package is enabled
3063
+ // Access non-resiliently if package optimization is enabled
3064
3064
if (bypassResilienceInPackage (M))
3065
3065
return false ;
3066
3066
return isResilient ();
@@ -4271,13 +4271,23 @@ bool ValueDecl::hasOpenAccess(const DeclContext *useDC) const {
4271
4271
}
4272
4272
4273
4273
bool ValueDecl::bypassResilienceInPackage (ModuleDecl *accessingModule) const {
4274
- // Client needs to opt in to bypass resilience checks at the use site.
4275
- // Client and the loaded module both need to be in the same package.
4276
- // The loaded module needs to be built from source and opt in to allow
4277
- // non-resilient access.
4278
- return getASTContext ().LangOpts .EnableBypassResilienceInPackage &&
4279
- getModuleContext ()->inSamePackage (accessingModule) &&
4280
- getModuleContext ()->allowNonResilientAccess ();
4274
+ auto declModule = getModuleContext ();
4275
+ if (declModule->inSamePackage (accessingModule) &&
4276
+ declModule->allowNonResilientAccess ()) {
4277
+ // If the defining module is built with package-cmo,
4278
+ // allow direct access from the use site that belongs
4279
+ // to accessingModule (client module).
4280
+ if (declModule->isResilient () &&
4281
+ declModule->serializePackageEnabled ())
4282
+ return true ;
4283
+
4284
+ // If not, check if the client can still opt in to
4285
+ // have a direct access to this decl from the use
4286
+ // site with a flag.
4287
+ // FIXME: serialize this flag to Module and get it via accessingModule.
4288
+ return getASTContext ().LangOpts .EnableBypassResilienceInPackage ;
4289
+ }
4290
+ return false ;
4281
4291
}
4282
4292
4283
4293
// / Given the formal access level for using \p VD, compute the scope where
@@ -5134,7 +5144,7 @@ bool NominalTypeDecl::isResilient(ModuleDecl *M,
5134
5144
// non-resiliently in a maximal context.
5135
5145
if (M == getModuleContext ())
5136
5146
return false ;
5137
- // Non-resilient if bypass optimization in package is enabled
5147
+ // Access non-resiliently if package optimization is enabled
5138
5148
if (bypassResilienceInPackage (M))
5139
5149
return false ;
5140
5150
0 commit comments