@@ -2788,6 +2788,9 @@ ValueDecl::getFormalAccessScope(const DeclContext *useDC,
27882788static bool checkAccessUsingAccessScopes (const DeclContext *useDC,
27892789 const ValueDecl *VD,
27902790 AccessLevel access) {
2791+ if (VD->getASTContext ().isAccessControlDisabled ())
2792+ return true ;
2793+
27912794 AccessScope accessScope =
27922795 getAccessScopeForFormalAccess (VD, access, useDC,
27932796 /* treatUsableFromInlineAsPublic*/ false );
@@ -2806,7 +2809,12 @@ static bool checkAccessUsingAccessScopes(const DeclContext *useDC,
28062809// /
28072810// / See ValueDecl::isAccessibleFrom for a description of \p forConformance.
28082811static bool checkAccess (const DeclContext *useDC, const ValueDecl *VD,
2809- AccessLevel access, bool forConformance) {
2812+ bool forConformance,
2813+ llvm::function_ref<AccessLevel()> getAccessLevel) {
2814+ if (VD->getASTContext ().isAccessControlDisabled ())
2815+ return true ;
2816+
2817+ auto access = getAccessLevel ();
28102818 auto *sourceDC = VD->getDeclContext ();
28112819
28122820 if (!forConformance) {
@@ -2868,8 +2876,8 @@ static bool checkAccess(const DeclContext *useDC, const ValueDecl *VD,
28682876
28692877bool ValueDecl::isAccessibleFrom (const DeclContext *useDC,
28702878 bool forConformance) const {
2871- auto access = getFormalAccess ();
2872- bool result = checkAccess (useDC, this , access, forConformance );
2879+ bool result = checkAccess (useDC, this , forConformance,
2880+ [&]() { return getFormalAccess (); } );
28732881
28742882 // For everything outside of protocols and operators, we should get the same
28752883 // result using either implementation of checkAccess, because useDC must
@@ -2878,9 +2886,9 @@ bool ValueDecl::isAccessibleFrom(const DeclContext *useDC,
28782886 // because we're finding internal operators within private types. Fortunately
28792887 // we have a requirement that a member operator take the enclosing type as an
28802888 // argument, so it won't ever match.
2881- assert (getDeclContext ()->getSelfProtocolDecl () ||
2882- isOperator () ||
2883- result == checkAccessUsingAccessScopes (useDC, this , access ));
2889+ assert (getDeclContext ()->getSelfProtocolDecl () || isOperator () ||
2890+ result ==
2891+ checkAccessUsingAccessScopes (useDC, this , getFormalAccess () ));
28842892
28852893 return result;
28862894}
@@ -2898,8 +2906,8 @@ bool AbstractStorageDecl::isSetterAccessibleFrom(const DeclContext *DC,
28982906 if (isa<ParamDecl>(this ))
28992907 return true ;
29002908
2901- auto access = getSetterFormalAccess ();
2902- return checkAccess (DC, this , access, forConformance );
2909+ return checkAccess (DC, this , forConformance,
2910+ [&]() { return getSetterFormalAccess (); } );
29032911}
29042912
29052913void ValueDecl::copyFormalAccessFrom (const ValueDecl *source,
0 commit comments