@@ -790,6 +790,23 @@ void UnboundImport::validateInterfaceWithPackageName(ModuleDecl *topLevelModule,
790
790
}
791
791
}
792
792
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
+
793
810
void UnboundImport::validateResilience (NullablePtr<ModuleDecl> topLevelModule,
794
811
SourceFile &SF) {
795
812
if (!topLevelModule)
@@ -825,14 +842,8 @@ void UnboundImport::validateResilience(NullablePtr<ModuleDecl> topLevelModule,
825
842
inFlight.fixItReplace (import .implementationOnlyRange , " internal" );
826
843
}
827
844
} 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 ())) {
836
847
ctx.Diags .diagnose (import .importLoc ,
837
848
diag::implementation_only_requires_library_evolution,
838
849
importerName);
0 commit comments