@@ -779,16 +779,29 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
779779 if (topLevelModule.get () == ctx.TheBuiltinModule )
780780 return ;
781781
782+ Identifier importerName = SF.getParentModule ()->getName (),
783+ targetName = topLevelModule.get ()->getName ();
784+
782785 // @_implementationOnly is only supported when used from modules built with
783786 // library-evolution. Otherwise it can lead to runtime crashes from a lack
784787 // of memory layout information when building clients unaware of the
785788 // dependency. The missing information is provided at run time by resilient
786789 // modules.
790+ // We exempt some imports using @_implementationOnly in a safe way from
791+ // packages that cannot be resilient.
787792 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" ))) {
789802 ctx.Diags .diagnose (import .importLoc ,
790803 diag::implementation_only_requires_library_evolution,
791- SF. getParentModule ()-> getName () );
804+ importerName );
792805 }
793806
794807 if (import .options .contains (ImportFlags::ImplementationOnly) ||
@@ -801,8 +814,7 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
801814
802815 auto inFlight = ctx.Diags .diagnose (import .module .getModulePath ().front ().Loc ,
803816 diag::module_not_compiled_with_library_evolution,
804- topLevelModule.get ()->getName (),
805- SF.getParentModule ()->getName ());
817+ targetName, importerName);
806818
807819 if (ctx.LangOpts .hasFeature (Feature::InternalImportsByDefault)) {
808820 // This will catch Swift 6 language mode as well where
0 commit comments