Excise "Accessibility" from the compiler (2/3)

"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
This commit is contained in:
Jordan Rose
2017-08-17 16:01:45 -07:00
parent 5f30eac288
commit 1c651973c3
66 changed files with 493 additions and 496 deletions

View File

@@ -1882,12 +1882,11 @@ static bool isDeclAttrRecord(unsigned ID) {
}
}
static Optional<swift::Accessibility>
getActualAccessLevel(uint8_t raw) {
static Optional<swift::AccessLevel> getActualAccessLevel(uint8_t raw) {
switch (serialization::AccessibilityKind(raw)) {
#define CASE(NAME) \
case serialization::AccessibilityKind::NAME: \
return Accessibility::NAME;
return AccessLevel::NAME;
CASE(Private)
CASE(FilePrivate)
CASE(Internal)
@@ -2500,8 +2499,8 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
assert(!assocType->getDeclaredInterfaceType()->hasError() &&
"erroneous associated type");
Accessibility parentAccess = cast<ProtocolDecl>(DC)->getFormalAccess();
assocType->setAccess(std::max(parentAccess,Accessibility::Internal));
AccessLevel parentAccess = cast<ProtocolDecl>(DC)->getFormalAccess();
assocType->setAccess(std::max(parentAccess, AccessLevel::Internal));
if (isImplicit)
assocType->setImplicit();
@@ -3390,7 +3389,7 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
if (isImplicit)
elem->setImplicit();
elem->setAccess(std::max(cast<EnumDecl>(DC)->getFormalAccess(),
Accessibility::Internal));
AccessLevel::Internal));
break;
}
@@ -3590,7 +3589,7 @@ ModuleFile::getDeclChecked(DeclID DID, Optional<DeclContext *> ForcedContext) {
configureGenericEnvironment(dtor, genericEnvID);
dtor->setAccess(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
Accessibility::Internal));
AccessLevel::Internal));
auto *selfParams = readParameterList();
selfParams->get(0)->setImplicit(); // self is implicit.

View File

@@ -1556,7 +1556,7 @@ void ModuleFile::loadExtensions(NominalTypeDecl *nominal) {
return;
if (nominal->hasAccess() &&
nominal->getEffectiveAccess() < Accessibility::Internal) {
nominal->getEffectiveAccess() < AccessLevel::Internal) {
if (nominal->getModuleScopeContext() != getFile())
return;
}

View File

@@ -1907,10 +1907,10 @@ getStableStaticSpelling(swift::StaticSpellingKind SS) {
llvm_unreachable("Unhandled StaticSpellingKind in switch.");
}
static uint8_t getRawStableAccessLevel(Accessibility access) {
static uint8_t getRawStableAccessLevel(AccessLevel access) {
switch (access) {
#define CASE(NAME) \
case Accessibility::NAME: \
case AccessLevel::NAME: \
return static_cast<uint8_t>(serialization::AccessibilityKind::NAME);
CASE(Private)
CASE(FilePrivate)
@@ -2438,7 +2438,7 @@ void Serializer::writeDecl(const Decl *D) {
if (auto *value = dyn_cast<ValueDecl>(D)) {
if (value->hasAccess() &&
value->getFormalAccess() <= Accessibility::FilePrivate &&
value->getFormalAccess() <= AccessLevel::FilePrivate &&
!value->getDeclContext()->isLocalContext()) {
// FIXME: We shouldn't need to encode this for /all/ private decls.
// In theory we can follow the same rules as mangling and only include
@@ -4245,7 +4245,7 @@ static void writeDeclCommentTable(
// we want to take the testability state into account
// and emit documentation if and only if they are visible to clients
// (which means public ordinarily, but public+internal when testing enabled).
if (VD->getEffectiveAccess() < Accessibility::Public)
if (VD->getEffectiveAccess() < AccessLevel::Public)
return true;
}
@@ -4408,7 +4408,7 @@ static void collectInterestingNestedDeclarations(
}
if (auto nestedType = dyn_cast<TypeDecl>(member)) {
if (nestedType->getEffectiveAccess() > Accessibility::FilePrivate) {
if (nestedType->getEffectiveAccess() > AccessLevel::FilePrivate) {
if (!nominalParent) {
const DeclContext *DC = member->getDeclContext();
nominalParent = DC->getAsNominalTypeOrNominalTypeExtensionContext();