@@ -790,6 +790,26 @@ 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 == " SwiftConcurrencyInternalShims" )
801+ return importerName == " _Concurrency" ;
802+
803+ if (targetName == " CCryptoBoringSSL" || targetName == " CCryptoBoringSSLShims" )
804+ return importerName == " Crypto" || importerName == " _CryptoExtras" ||
805+ importerName == " CryptoBoringWrapper" ;
806+
807+ if (targetName == " CNIOBoringSSL" || targetName == " CNIOBoringSSLShims" )
808+ return importerName != " NIOSSL" ;
809+
810+ return false ;
811+ }
812+
793813void UnboundImport::validateResilience (NullablePtr<ModuleDecl> topLevelModule,
794814 SourceFile &SF) {
795815 if (!topLevelModule)
@@ -825,14 +845,8 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
825845 inFlight.fixItReplace (import .implementationOnlyRange , " internal" );
826846 }
827847 } 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" ))) {
848+ !shouldSuppressNonResilientImplementationOnlyImportDiagnostic (
849+ targetName.str (), importerName.str ())) {
836850 ctx.Diags .diagnose (import .importLoc ,
837851 diag::implementation_only_requires_library_evolution,
838852 importerName);
0 commit comments