@@ -779,16 +779,29 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
779
779
if (topLevelModule.get () == ctx.TheBuiltinModule )
780
780
return ;
781
781
782
+ Identifier importerName = SF.getParentModule ()->getName (),
783
+ targetName = topLevelModule.get ()->getName ();
784
+
782
785
// @_implementationOnly is only supported when used from modules built with
783
786
// library-evolution. Otherwise it can lead to runtime crashes from a lack
784
787
// of memory layout information when building clients unaware of the
785
788
// dependency. The missing information is provided at run time by resilient
786
789
// modules.
790
+ // We exempt some imports using @_implementationOnly in a safe way from
791
+ // packages that cannot be resilient.
787
792
if (import .options .contains (ImportFlags::ImplementationOnly) &&
788
- !SF.getParentModule ()->isResilient () && topLevelModule) {
793
+ !SF.getParentModule ()->isResilient () && topLevelModule &&
794
+ !(((targetName.str () == " CCryptoBoringSSL" ||
795
+ targetName.str () == " CCryptoBoringSSLShims" ) &&
796
+ (importerName.str () == " Crypto" ||
797
+ importerName.str () == " _CryptoExtras" ||
798
+ importerName.str () == " CryptoBoringWrapper" )) ||
799
+ ((targetName.str () == " CNIOBoringSSL" ||
800
+ targetName.str () == " CNIOBoringSSLShims" ) &&
801
+ importerName.str () == " NIOSSL" ))) {
789
802
ctx.Diags .diagnose (import .importLoc ,
790
803
diag::implementation_only_requires_library_evolution,
791
- SF. getParentModule ()-> getName () );
804
+ importerName );
792
805
}
793
806
794
807
if (import .options .contains (ImportFlags::ImplementationOnly) ||
@@ -801,8 +814,7 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
801
814
802
815
auto inFlight = ctx.Diags .diagnose (import .module .getModulePath ().front ().Loc ,
803
816
diag::module_not_compiled_with_library_evolution,
804
- topLevelModule.get ()->getName (),
805
- SF.getParentModule ()->getName ());
817
+ targetName, importerName);
806
818
807
819
if (ctx.LangOpts .hasFeature (Feature::InternalImportsByDefault)) {
808
820
// This will catch Swift 6 language mode as well where
0 commit comments