Serialization: Error on xref to implementation-only dependencies

Introduce a last resort check reporting references to
implementation-only dependencies that would appear in the generated
swiftmodule. This check is applied at serialization, long after
exportability checking applied at typechecking. It should act as a back
stop to references missed by typechecking or @_implementationOnly decls
that should have been skipped.

This check is gated behind CheckImplementationOnlyStrict and should be
used with embedded only.

rdar://160697599
This commit is contained in:
Alexis Laferrière
2025-10-20 13:57:11 -07:00
parent ac41fb60ff
commit 5a49e34426
6 changed files with 180 additions and 8 deletions

View File

@@ -1064,11 +1064,15 @@ public:
void
getImportedModulesForLookup(SmallVectorImpl<ImportedModule> &imports) const;
/// Has \p module been imported via an '@_implementationOnly' import
/// instead of another kind of import?
/// Has \p module been imported via an '@_implementationOnly' import and
/// not by anything more visible?
///
/// This assumes that \p module was imported.
bool isImportedImplementationOnly(const ModuleDecl *module) const;
/// If \p assumeImported, assume that \p module was imported and avoid the
/// work to confirm it is imported at all. Transitive modules not reexported
/// are not considered imported here and may lead to false positive without
/// this setting.
bool isImportedImplementationOnly(const ModuleDecl *module,
bool assumeImported = true) const;
/// Finds all top-level decls of this module.
///