[SR-2209] Make a real AccessScope class and use it in access checking.

1. Add new AccessScope type that just wraps a plain DeclContext.
2. Propagate it into all uses of "ValueDecl::getFormalAccessScope".
3. Turn all operations that combine access scopes into methods on AccessScope.
4. Add the "private" flag to distinguish "private" from "fileprivate"
scope for top-level DeclContext.
This commit is contained in:
Aleksey Gaponov
2016-09-15 21:51:25 +02:00
parent e11ad5d2f7
commit f51b2d12c4
11 changed files with 246 additions and 208 deletions

View File

@@ -15,6 +15,7 @@
//===----------------------------------------------------------------------===//
#include "swift/AST/Module.h"
#include "swift/AST/AccessScope.h"
#include "swift/AST/AST.h"
#include "swift/AST/ASTPrinter.h"
#include "swift/AST/ASTScope.h"
@@ -428,8 +429,8 @@ void Module::lookupMember(SmallVectorImpl<ValueDecl*> &results,
return VD->getModuleContext() == this;
});
const DeclContext *accessScope = nominal->getFormalAccessScope();
if (accessScope && !accessScope->isModuleContext())
auto AS = nominal->getFormalAccessScope();
if (AS.isPrivate() || AS.isFileScope())
alreadyInPrivateContext = true;
break;