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

@@ -887,6 +887,10 @@ REMARK(serialization_skipped_invalid_type_unknown_name,none,
ERROR(serialization_failed,none,
"serialization of module %0 failed due to the errors above",
(const ModuleDecl *))
ERROR(serialization_xref_to_hidden_dependency,none,
"invalid reference to implementation-only imported module %0"
"%select{| for %1}1",
(const ModuleDecl *, const Decl *))
WARNING(can_import_invalid_swiftmodule,none,
"canImport() evaluated to false due to invalid swiftmodule: %0", (StringRef))