mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Currently decls defined with package access level have a different
access level for optimization: `public`. It requires an extra check for the actual access level that was declared when determining serialization since the behavior should be different. This PR sets its effective access level to `package` as originally defined, updates call sites to make appropriate acces level comparisons, and removes `package` specific checks.
This commit is contained in:
@@ -4157,17 +4157,7 @@ AccessLevel ValueDecl::getEffectiveAccess() const {
|
||||
// Handle @testable/@_private(sourceFile:)
|
||||
switch (effectiveAccess) {
|
||||
case AccessLevel::Open:
|
||||
break;
|
||||
case AccessLevel::Package:
|
||||
if (getModuleContext()->isTestingEnabled() ||
|
||||
getModuleContext()->arePrivateImportsEnabled()) {
|
||||
effectiveAccess = getMaximallyOpenAccessFor(this);
|
||||
} else {
|
||||
// Package declarations are effectively public within their
|
||||
// package unit.
|
||||
effectiveAccess = AccessLevel::Public;
|
||||
}
|
||||
break;
|
||||
case AccessLevel::Public:
|
||||
case AccessLevel::Internal:
|
||||
if (getModuleContext()->isTestingEnabled() ||
|
||||
@@ -5900,9 +5890,9 @@ bool ClassDecl::hasResilientMetadata() const {
|
||||
if (!getModuleContext()->isResilient())
|
||||
return false;
|
||||
|
||||
// If the class is not public, we can't use it outside the module at all.
|
||||
// If the class is not public or package, we can't use it outside the module at all.
|
||||
// Take enable testing into account.
|
||||
if (getEffectiveAccess() < AccessLevel::Public)
|
||||
if (getEffectiveAccess() < AccessLevel::Package)
|
||||
return false;
|
||||
|
||||
// Otherwise we access metadata members, such as vtable entries, resiliently.
|
||||
|
||||
Reference in New Issue
Block a user