@@ -550,11 +550,12 @@ void AccessControlCheckerBase::checkGenericParamAccess(
550550 if (minAccessScope.isPublic ())
551551 return ;
552552
553- // FIXME: Promote these to an error in the next -swift-version break.
554- if (isa<SubscriptDecl>(ownerDecl) || isa<TypeAliasDecl>(ownerDecl))
553+ auto &Context = ownerDecl->getASTContext ();
554+
555+ if (!Context.LangOpts .hasFeature (Feature::StrictAccessControl) &&
556+ (isa<SubscriptDecl>(ownerDecl) || isa<TypeAliasDecl>(ownerDecl)))
555557 downgradeToWarning = DowngradeToWarning::Yes;
556558
557- auto &Context = ownerDecl->getASTContext ();
558559 if (checkUsableFromInline) {
559560 if (!Context.isLanguageModeAtLeast (5 ))
560561 downgradeToWarning = DowngradeToWarning::Yes;
@@ -2042,14 +2043,16 @@ swift::getDisallowedOriginKind(const Decl *decl,
20422043 downgradeToWarning = DowngradeToWarning::No;
20432044 ModuleDecl *M = decl->getModuleContext ();
20442045 auto *SF = where.getDeclContext ()->getParentSourceFile ();
2046+ auto &Context = M->getASTContext ();
20452047
20462048 RestrictedImportKind howImported = SF->getRestrictedImportKind (M);
20472049 if (howImported != RestrictedImportKind::None) {
20482050 // Temporarily downgrade implementation-only exportability in SPI to
20492051 // a warning.
2050- if (where.isSPI () &&
2052+ if (!Context.LangOpts .hasFeature (Feature::StrictAccessControl) &&
2053+ where.isSPI () &&
20512054 where.getFragileFunctionKind ().kind == FragileFunctionKind::None &&
2052- !SF-> getASTContext () .LangOpts .EnableSPIOnlyImports )
2055+ !Context .LangOpts .EnableSPIOnlyImports )
20532056 downgradeToWarning = DowngradeToWarning::Yes;
20542057
20552058 if (where.isSPI () && howImported == RestrictedImportKind::SPIOnly)
@@ -2058,8 +2061,9 @@ swift::getDisallowedOriginKind(const Decl *decl,
20582061 // Before Swift 6, implicit imports were not reported unless an
20592062 // implementation-only import was also present. Downgrade to a warning
20602063 // just in this case.
2061- if (howImported == RestrictedImportKind::MissingImport &&
2062- !SF->getASTContext ().isLanguageModeAtLeast (6 ) &&
2064+ if (!Context.LangOpts .hasFeature (Feature::StrictAccessControl) &&
2065+ howImported == RestrictedImportKind::MissingImport &&
2066+ !Context.isLanguageModeAtLeast (6 ) &&
20632067 !SF->hasImportsWithFlag (ImportFlags::ImplementationOnly)) {
20642068 downgradeToWarning = DowngradeToWarning::Yes;
20652069 }
@@ -2087,7 +2091,7 @@ swift::getDisallowedOriginKind(const Decl *decl,
20872091 if (!owningModule)
20882092 continue ;
20892093 auto moduleWrapper =
2090- decl-> getASTContext () .getClangModuleLoader ()->getWrapperForModule (
2094+ Context .getClangModuleLoader ()->getWrapperForModule (
20912095 owningModule);
20922096 auto visibleAccessPath =
20932097 find_if (sfImportedModules, [&moduleWrapper](auto importedModule) {
@@ -2150,7 +2154,7 @@ swift::getDisallowedOriginKind(const Decl *decl,
21502154 }
21512155
21522156 // C++ APIs do not support library evolution.
2153- if (SF-> getASTContext () .LangOpts .EnableCXXInterop && where.getDeclContext () &&
2157+ if (Context .LangOpts .EnableCXXInterop && where.getDeclContext () &&
21542158 where.getDeclContext ()->getAsDecl () &&
21552159 where.getDeclContext ()->getAsDecl ()->getModuleContext ()->isResilient () &&
21562160 !where.getDeclContext ()
@@ -2159,13 +2163,13 @@ swift::getDisallowedOriginKind(const Decl *decl,
21592163 ->getUnderlyingModuleIfOverlay () &&
21602164 decl->hasClangNode () && !decl->getModuleContext ()->isSwiftShimsModule () &&
21612165 isFragileClangNode (decl->getClangNode ()) &&
2162- !SF-> getASTContext () .LangOpts .hasFeature (
2166+ !Context .LangOpts .hasFeature (
21632167 Feature::AssumeResilientCxxTypes))
21642168 return DisallowedOriginKind::FragileCxxAPI;
21652169
21662170 // Implementation-only memory layouts for non-library-evolution mode.
21672171 if (isa<NominalTypeDecl>(decl) &&
2168- decl-> getASTContext () .LangOpts .hasFeature (
2172+ Context .LangOpts .hasFeature (
21692173 Feature::CheckImplementationOnly) &&
21702174 decl->getAttrs ().hasAttribute <ImplementationOnlyAttr>())
21712175 return DisallowedOriginKind::ImplementationOnlyMemoryLayout;
0 commit comments