Default access for many synthesized members to 'internal'.

More detail: some members are intended to have the same the access as
their containing types. This doesn't fly for SE-0025 'private', which
would limit the members to only being accessed from lexically within
the type decl, instead anywhere the type itself can be seen. Instead,
follow the rule for user-written members---internal by default---and
then raise the access level to 'public' if necessary. This affects:

- enum cases
- deinitializers
- protocol requirements
- generic parameters
- implicit initializers
- inherited initializers
- derived conformance members
- synthesized typealiases for associated types
This commit is contained in:
Jordan Rose
2016-07-25 17:52:21 -07:00
parent a965e22ae4
commit c70a5a5d67
10 changed files with 93 additions and 46 deletions

View File

@@ -3036,7 +3036,8 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
elem->setInterfaceType(interfaceType);
if (isImplicit)
elem->setImplicit();
elem->setAccessibility(cast<EnumDecl>(DC)->getFormalAccess());
elem->setAccessibility(std::max(cast<EnumDecl>(DC)->getFormalAccess(),
Accessibility::Internal));
break;
}
@@ -3203,7 +3204,8 @@ Decl *ModuleFile::getDecl(DeclID DID, Optional<DeclContext *> ForcedContext) {
/*selfpat*/nullptr, DC);
declOrOffset = dtor;
dtor->setAccessibility(cast<ClassDecl>(DC)->getFormalAccess());
dtor->setAccessibility(std::max(cast<ClassDecl>(DC)->getFormalAccess(),
Accessibility::Internal));
auto *selfParams = readParameterList();
selfParams->get(0)->setImplicit(); // self is implicit.