Skip to content

Commit 05ea885

Browse files
committed
AST: More renaming of 'versioned' things
1 parent 6198f30 commit 05ea885

File tree

4 files changed

+22
-17
lines changed

4 files changed

+22
-17
lines changed

lib/AST/Decl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,8 +2140,9 @@ static AccessLevel getTestableAccess(const ValueDecl *decl) {
21402140
}
21412141

21422142
AccessLevel ValueDecl::getEffectiveAccess() const {
2143-
auto effectiveAccess = getFormalAccess(/*useDC=*/nullptr,
2144-
/*respectVersionedAttr=*/true);
2143+
auto effectiveAccess =
2144+
getFormalAccess(/*useDC=*/nullptr,
2145+
/*treatUsableFromInlineAsPublic=*/true);
21452146

21462147
// Handle @testable.
21472148
switch (effectiveAccess) {

lib/AST/DeclContext.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,10 @@ ResilienceExpansion DeclContext::getResilienceExpansion() const {
364364
// if the type is formally fixed layout.
365365
if (isa<PatternBindingInitializer>(dc)) {
366366
if (auto *NTD = dyn_cast<NominalTypeDecl>(dc->getParent())) {
367-
if (!NTD->getFormalAccessScope(/*useDC=*/nullptr,
368-
/*respectVersionedAttr=*/true).isPublic())
367+
auto nominalAccess =
368+
NTD->getFormalAccessScope(/*useDC=*/nullptr,
369+
/*treatUsableFromInlineAsPublic=*/true);
370+
if (!nominalAccess.isPublic())
369371
return ResilienceExpansion::Maximal;
370372

371373
if (NTD->isFormallyResilient())
@@ -386,10 +388,13 @@ ResilienceExpansion DeclContext::getResilienceExpansion() const {
386388
if (!AFD->hasAccess())
387389
break;
388390

391+
auto funcAccess =
392+
AFD->getFormalAccessScope(/*useDC=*/nullptr,
393+
/*treatUsableFromInlineAsPublic=*/true);
394+
389395
// If the function is not externally visible, we will not be serializing
390396
// its body.
391-
if (!AFD->getFormalAccessScope(/*useDC=*/nullptr,
392-
/*respectVersionedAttr=*/true).isPublic())
397+
if (!funcAccess.isPublic())
393398
break;
394399

395400
// Bodies of public transparent and always-inline functions are

lib/SIL/SILDeclRef.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -456,8 +456,9 @@ IsSerialized_t SILDeclRef::isSerialized() const {
456456
// marked as @_fixed_layout.
457457
if (isStoredPropertyInitializer()) {
458458
auto *nominal = cast<NominalTypeDecl>(d->getDeclContext());
459-
auto scope = nominal->getFormalAccessScope(/*useDC=*/nullptr,
460-
/*respectVersionedAttr=*/true);
459+
auto scope =
460+
nominal->getFormalAccessScope(/*useDC=*/nullptr,
461+
/*treatUsableFromInlineAsPublic=*/true);
461462
if (!scope.isPublic())
462463
return IsNotSerialized;
463464
if (nominal->isFormallyResilient())

lib/Sema/TypeCheckStmt.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,29 +1397,27 @@ static void checkDefaultArguments(TypeChecker &tc,
13971397
/// Check the default arguments that occur within this pattern.
13981398
void TypeChecker::checkDefaultArguments(ArrayRef<ParameterList *> paramLists,
13991399
ValueDecl *VD) {
1400+
auto access =
1401+
VD->getFormalAccessScope(/*useDC=*/nullptr,
1402+
/*treatUsableFromInlineAsPublic=*/true);
1403+
14001404
// In Swift 4 mode, default argument bodies are inlined into the
14011405
// caller.
14021406
if (auto *func = dyn_cast<AbstractFunctionDecl>(VD)) {
14031407
auto expansion = func->getResilienceExpansion();
1404-
if (!Context.isSwiftVersion3() &&
1405-
func->getFormalAccessScope(/*useDC=*/nullptr,
1406-
/*respectVersionedAttr=*/true).isPublic())
1408+
if (!Context.isSwiftVersion3() && access.isPublic())
14071409
expansion = ResilienceExpansion::Minimal;
14081410

14091411
func->setDefaultArgumentResilienceExpansion(expansion);
14101412
} else {
14111413
auto *EED = cast<EnumElementDecl>(VD);
1412-
auto expansion = EED->getParentEnum()->getResilienceExpansion();
1413-
// Enum payloads parameter lists may have default arguments as of Swift 5.
1414-
if (Context.isSwiftVersionAtLeast(5) &&
1415-
EED->getFormalAccessScope(/*useDC=*/nullptr,
1416-
/*respectVersionedAttr=*/true).isPublic())
1414+
auto expansion = ResilienceExpansion::Maximal;
1415+
if (access.isPublic())
14171416
expansion = ResilienceExpansion::Minimal;
14181417

14191418
EED->setDefaultArgumentResilienceExpansion(expansion);
14201419
}
14211420

1422-
14231421
unsigned nextArgIndex = 0;
14241422
for (auto *paramList : paramLists)
14251423
::checkDefaultArguments(*this, paramList, nextArgIndex);

0 commit comments

Comments
 (0)