Skip to content

Commit bdd4503

Browse files
author
Robert Widmann
committed
Fix the Effective Access Level of package Declarations
swiftc mis-compiles package declarations today because it reports the effective access level of package declarations as less than public. There are a bunch of places in the optimizer that are checking the effective access level against an upper bound of public, so a lot of code winds up internalized or optimized as though it were internal when it definitely is not. Fixes rdar://118081829
1 parent 1f363be commit bdd4503

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/AST/Decl.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4120,6 +4120,15 @@ AccessLevel ValueDecl::getEffectiveAccess() const {
41204120
case AccessLevel::Open:
41214121
break;
41224122
case AccessLevel::Package:
4123+
if (getModuleContext()->isTestingEnabled() ||
4124+
getModuleContext()->arePrivateImportsEnabled()) {
4125+
effectiveAccess = getMaximallyOpenAccessFor(this);
4126+
} else {
4127+
// Package declarations are effectively public within their
4128+
// package unit.
4129+
effectiveAccess = AccessLevel::Public;
4130+
}
4131+
break;
41234132
case AccessLevel::Public:
41244133
case AccessLevel::Internal:
41254134
if (getModuleContext()->isTestingEnabled() ||

0 commit comments

Comments
 (0)