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:
Ellie Shin
2024-01-12 14:31:49 -08:00
parent b4dbd97c34
commit ab3b5add3a
10 changed files with 17 additions and 28 deletions

View File

@@ -328,7 +328,7 @@ bool CrossModuleOptimization::canSerializeInstruction(SILInstruction *inst,
// properties, because that would require to make the field decl public -
// which keeps more metadata alive.
return !conservative ||
REAI->getField()->getEffectiveAccess() >= AccessLevel::Public;
REAI->getField()->getEffectiveAccess() >= AccessLevel::Package;
}
return true;
}
@@ -365,7 +365,7 @@ bool CrossModuleOptimization::canSerializeType(SILType type) {
CanType subType = rawSubType->getCanonicalType();
if (NominalTypeDecl *subNT = subType->getNominalOrBoundGenericNominal()) {
if (conservative && subNT->getEffectiveAccess() < AccessLevel::Public) {
if (conservative && subNT->getEffectiveAccess() < AccessLevel::Package) {
return true;
}
@@ -596,7 +596,7 @@ void CrossModuleOptimization::makeFunctionUsableFromInline(SILFunction *function
/// Make a nominal type, including it's context, usable from inline.
void CrossModuleOptimization::makeDeclUsableFromInline(ValueDecl *decl) {
if (decl->getEffectiveAccess() >= AccessLevel::Public)
if (decl->getEffectiveAccess() >= AccessLevel::Package)
return;
// We must not modify decls which are defined in other modules.