Skip to content

Commit 377f23f

Browse files
authored
Merge pull request swiftlang#35863 from slavapestov/remove-spi-from-access-scope
AST: Remove SPI bit from AccessScope
2 parents 0282cf5 + 9ca2a70 commit 377f23f

File tree

3 files changed

+6
-16
lines changed

3 files changed

+6
-16
lines changed

include/swift/AST/AccessScope.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class AccessScope {
3131
llvm::PointerIntPair<const DeclContext *, 1, bool> Value;
3232

3333
public:
34-
AccessScope(const DeclContext *DC, bool isPrivate = false, bool isSPI = false);
34+
AccessScope(const DeclContext *DC, bool isPrivate = false);
3535

36-
static AccessScope getPublic(bool isSPI = false) { return AccessScope(nullptr, false, isSPI); }
36+
static AccessScope getPublic() { return AccessScope(nullptr, false); }
3737

3838
/// Check if private access is allowed. This is a lexical scope check in Swift
3939
/// 3 mode. In Swift 4 mode, declarations and extensions of the same type will
@@ -54,20 +54,14 @@ class AccessScope {
5454
bool isFileScope() const;
5555
bool isInternal() const;
5656

57-
// Is this a public scope
58-
bool isSPI() const { return !Value.getPointer() && Value.getInt(); }
59-
6057
/// Returns true if this is a child scope of the specified other access scope.
6158
///
6259
/// \see DeclContext::isChildContextOf
6360
bool isChildOf(AccessScope AS) const {
6461
if (!isPublic() && !AS.isPublic())
6562
return allowsPrivateAccess(getDeclContext(), AS.getDeclContext());
66-
if (isPublic() && AS.isPublic()) {
67-
if (isSPI() != AS.isSPI())
68-
return isSPI();
63+
if (isPublic() && AS.isPublic())
6964
return false;
70-
}
7165
return AS.isPublic();
7266
}
7367

@@ -86,8 +80,6 @@ class AccessScope {
8680
/// have common intersection, or None if scopes don't intersect.
8781
const Optional<AccessScope> intersectWith(AccessScope accessScope) const {
8882
if (hasEqualDeclContextWith(accessScope)) {
89-
if (isSPI())
90-
return *this;
9183
if (isPrivate())
9284
return *this;
9385
return accessScope;

lib/AST/Decl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3298,7 +3298,7 @@ getAccessScopeForFormalAccess(const ValueDecl *VD,
32983298
return AccessScope(resultDC->getParentModule());
32993299
case AccessLevel::Public:
33003300
case AccessLevel::Open:
3301-
return AccessScope::getPublic(VD->isSPI());
3301+
return AccessScope::getPublic();
33023302
}
33033303

33043304
llvm_unreachable("unknown access level");

lib/AST/DeclContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,16 +1058,14 @@ getPrivateDeclContext(const DeclContext *DC, const SourceFile *useSF) {
10581058
return lastExtension ? lastExtension : DC;
10591059
}
10601060

1061-
AccessScope::AccessScope(const DeclContext *DC, bool isPrivate, bool isSPI)
1062-
: Value(DC, isPrivate || isSPI) {
1061+
AccessScope::AccessScope(const DeclContext *DC, bool isPrivate)
1062+
: Value(DC, isPrivate) {
10631063
if (isPrivate) {
10641064
DC = getPrivateDeclContext(DC, DC->getParentSourceFile());
10651065
Value.setPointer(DC);
10661066
}
10671067
if (!DC || isa<ModuleDecl>(DC))
10681068
assert(!isPrivate && "public or internal scope can't be private");
1069-
if (DC)
1070-
assert(!isSPI && "only public scopes can be SPI");
10711069
}
10721070

10731071
bool AccessScope::isFileScope() const {

0 commit comments

Comments
 (0)