Sema: Warn on all non-resilient uses of @_implementationOnly, even for clang targets

The warnings about `using '@_implementationOnly' without enabling library evolution for 'client'
may lead to instability during execution` and `@_implementationOnly' is deprecated, use
'internal import' instead` were wrongly restricted to only Swift import targets.
Make sure they are raised for clang module targets as well.

rdar://135233043
This commit is contained in:
Alexis Laferrière
2024-09-04 11:51:22 -07:00
parent 2eade1e3cc
commit 3995ee4bbf
2 changed files with 42 additions and 15 deletions

View File

@@ -792,11 +792,7 @@ void UnboundImport::validateInterfaceWithPackageName(ModuleDecl *topLevelModule,
void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
SourceFile &SF) {
ASTContext &ctx = SF.getASTContext();
// Per getTopLevelModule(), we'll only get nullptr here for non-Swift modules,
// so these two really mean the same thing.
if (!topLevelModule || topLevelModule.get()->isNonSwiftModule())
if (!topLevelModule)
return;
// If the module we're validating is the builtin one, then just return because
@@ -804,6 +800,7 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
// itself with resiliency. This can occur when one has passed
// '-enable-builtin-module' and is explicitly importing the Builtin module in
// their sources.
ASTContext &ctx = SF.getASTContext();
if (topLevelModule.get() == ctx.TheBuiltinModule)
return;
@@ -841,7 +838,8 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
}
// Report public imports of non-resilient modules from a resilient module.
if (import.options.contains(ImportFlags::ImplementationOnly) ||
if (topLevelModule.get()->isNonSwiftModule() ||
import.options.contains(ImportFlags::ImplementationOnly) ||
import.accessLevel < AccessLevel::Public)
return;