File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change 20
20
#include " swift/Strings.h"
21
21
#include " swift/AST/ASTWalker.h"
22
22
#include " swift/AST/GenericEnvironment.h"
23
+ #include " swift/AST/ImportCache.h"
23
24
#include " swift/AST/Initializer.h"
24
25
#include " swift/AST/ParameterList.h"
25
26
#include " swift/AST/ProtocolConformance.h"
@@ -686,11 +687,23 @@ static Optional<AttributedImport<ImportedModule>> findImportFor(
686
687
if (!fromSourceFile)
687
688
return None;
688
689
690
+ // Look to see if the owning module was directly imported.
689
691
for (const auto &import : fromSourceFile->getImports ()) {
690
692
if (import .module .importedModule == nominalModule)
691
693
return import ;
692
694
}
693
695
696
+ // Now look for transitive imports.
697
+ auto &importCache = nominal->getASTContext ().getImportCache ();
698
+ for (const auto &import : fromSourceFile->getImports ()) {
699
+ auto &importSet = importCache.getImportSet (import .module .importedModule );
700
+ for (const auto &transitive : importSet.getTransitiveImports ()) {
701
+ if (transitive.importedModule == nominalModule) {
702
+ return import ;
703
+ }
704
+ }
705
+ }
706
+
694
707
return None;
695
708
}
696
709
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+
3
+ // FIXME: BEGIN -enable-source-import hackaround
4
+ // RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -I %S/Inputs/custom-modules %s -verify -swift-version 6
5
+
6
+ // REQUIRES: objc_interop
7
+ // REQUIRES: concurrency
8
+ // REQUIRES: asserts
9
+
10
+ @_predatesConcurrency import Foundation
11
+
12
+ func acceptSendable< T: Sendable > ( _: T ) { }
13
+
14
+ func useSendable( ns: NSString ) {
15
+ // Note: warning below is downgraded due to @_predatesConcurrency
16
+ acceptSendable ( ns) // expected-warning{{type 'NSString' does not conform to the 'Sendable' protocol}}
17
+ }
You can’t perform that action at this time.
0 commit comments