@@ -790,6 +790,23 @@ void UnboundImport::validateInterfaceWithPackageName(ModuleDecl *topLevelModule,
790790 }
791791}
792792
793+ // / Returns true if the importer and importee tuple are on an allow list for
794+ // / use of `@_implementationOnly import`, which is deprecated. Some existing
795+ // / uses of `@_implementationOnly import` cannot be safely replaced by
796+ // / `internal import` because the existence of the imported module must always
797+ // / be hidden from clients.
798+ static bool shouldSuppressNonResilientImplementationOnlyImportDiagnostic (
799+ StringRef targetName, StringRef importerName) {
800+ if (targetName == " CCryptoBoringSSL" || targetName == " CCryptoBoringSSLShims" )
801+ return importerName == " Crypto" || importerName == " _CryptoExtras" ||
802+ importerName == " CryptoBoringWrapper" ;
803+
804+ if (targetName == " CNIOBoringSSL" || targetName == " CNIOBoringSSLShims" )
805+ return importerName != " NIOSSL" ;
806+
807+ return false ;
808+ }
809+
793810void UnboundImport::validateResilience (NullablePtr<ModuleDecl> topLevelModule,
794811 SourceFile &SF) {
795812 if (!topLevelModule)
@@ -825,14 +842,8 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
825842 inFlight.fixItReplace (import .implementationOnlyRange , " internal" );
826843 }
827844 } else if ( // Non-resilient client
828- !(((targetName.str () == " CCryptoBoringSSL" ||
829- targetName.str () == " CCryptoBoringSSLShims" ) &&
830- (importerName.str () == " Crypto" ||
831- importerName.str () == " _CryptoExtras" ||
832- importerName.str () == " CryptoBoringWrapper" )) ||
833- ((targetName.str () == " CNIOBoringSSL" ||
834- targetName.str () == " CNIOBoringSSLShims" ) &&
835- importerName.str () == " NIOSSL" ))) {
845+ !shouldSuppressNonResilientImplementationOnlyImportDiagnostic (
846+ targetName.str (), importerName.str ())) {
836847 ctx.Diags .diagnose (import .importLoc ,
837848 diag::implementation_only_requires_library_evolution,
838849 importerName);
0 commit comments