@@ -810,38 +810,6 @@ static bool hasExplicitSendableConformance(NominalTypeDecl *nominal,
810
810
conformance.getConcrete ())->isMissing ());
811
811
}
812
812
813
- // / Find the import that makes the given declaration available.
814
- static llvm::Optional<AttributedImport<ImportedModule>>
815
- findImportFor (const DeclContext *dc, const DeclContext *fromDC) {
816
- // If the type is from the current module, there's no import.
817
- auto module = dc->getParentModule ();
818
- if (module == fromDC->getParentModule ())
819
- return llvm::None;
820
-
821
- auto fromSourceFile = fromDC->getParentSourceFile ();
822
- if (!fromSourceFile)
823
- return llvm::None;
824
-
825
- // Look to see if the owning module was directly imported.
826
- for (const auto &import : fromSourceFile->getImports ()) {
827
- if (import .module .importedModule == module )
828
- return import ;
829
- }
830
-
831
- // Now look for transitive imports.
832
- auto &importCache = dc->getASTContext ().getImportCache ();
833
- for (const auto &import : fromSourceFile->getImports ()) {
834
- auto &importSet = importCache.getImportSet (import .module .importedModule );
835
- for (const auto &transitive : importSet.getTransitiveImports ()) {
836
- if (transitive.importedModule == module ) {
837
- return import ;
838
- }
839
- }
840
- }
841
-
842
- return llvm::None;
843
- }
844
-
845
813
// / Determine the diagnostic behavior for a Sendable reference to the given
846
814
// / nominal type.
847
815
DiagnosticBehavior SendableCheckContext::diagnosticBehavior (
@@ -870,7 +838,7 @@ SendableCheckContext::preconcurrencyBehavior(Decl *decl) const {
870
838
if (auto *nominal = dyn_cast<NominalTypeDecl>(decl)) {
871
839
// Determine whether this nominal type is visible via a @preconcurrency
872
840
// import.
873
- auto import = findImportFor ( nominal, fromDC);
841
+ auto import = nominal-> findImport ( fromDC);
874
842
auto sourceFile = fromDC->getParentSourceFile ();
875
843
876
844
if (!import || !import ->options .contains (ImportFlags::Preconcurrency))
@@ -937,7 +905,7 @@ bool swift::diagnoseSendabilityErrorBasedOn(
937
905
// This type was imported from another module; try to find the
938
906
// corresponding import.
939
907
llvm::Optional<AttributedImport<swift::ImportedModule>> import =
940
- findImportFor ( nominal, fromContext.fromDC );
908
+ nominal-> findImport ( fromContext.fromDC );
941
909
942
910
// If we found the import that makes this nominal type visible, remark
943
911
// that it can be @preconcurrency import.
@@ -3012,8 +2980,7 @@ namespace {
3012
2980
return false ;
3013
2981
}
3014
2982
3015
- const auto import =
3016
- findImportFor (var->getDeclContext (), getDeclContext ());
2983
+ const auto import = var->findImport (getDeclContext ());
3017
2984
const bool isPreconcurrencyImport =
3018
2985
import && import ->options .contains (ImportFlags::Preconcurrency);
3019
2986
const auto isPreconcurrencyUnspecifiedIsolation =
0 commit comments