Add a missing check for a corner case with package use site / internal decl site

Update tests

Resolves rdar://106732804, rdar://104987455
This commit is contained in:
Ellie Shin
2023-03-27 17:04:30 -07:00
parent f3524ad197
commit 772e42e448
5 changed files with 111 additions and 88 deletions

View File

@@ -4112,6 +4112,11 @@ static bool checkAccess(const DeclContext *useDC, const ValueDecl *VD,
}
return true;
case AccessLevel::Internal: {
// Invalid if the use site is > Internal.
// E.g. extension containing a member of a protocol it conforms to has
// `package` access level but the member is `internal`
if (useDC->getContextKind() == DeclContextKind::Package)
return false;
const ModuleDecl *sourceModule = sourceDC->getParentModule();
const DeclContext *useFile = useDC->getModuleScopeContext();
if (useFile->getParentModule() == sourceModule)