File tree 5 files changed +46
-0
lines changed
5 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -916,6 +916,10 @@ static ModuleDecl *getModuleContextForNameLookupForCxxDecl(const Decl *decl) {
916
916
if (!clangModule)
917
917
return nullptr ;
918
918
919
+ // Swift groups all submodules of a Clang module together, and imports them as
920
+ // a single top-level module.
921
+ clangModule = clangModule->getTopLevelModule ();
922
+
919
923
return ctx.getClangModuleLoader ()->getWrapperForModule (clangModule);
920
924
}
921
925
Original file line number Diff line number Diff line change
1
+ namespace NS {
2
+ } // namespace NS
Original file line number Diff line number Diff line change
1
+ namespace NS {
2
+
3
+ struct MyStructInDeepSubModule {};
4
+
5
+ } // namespace NS
Original file line number Diff line number Diff line change @@ -2,3 +2,18 @@ module Namespaces {
2
2
header "namespace.h"
3
3
requires cplusplus
4
4
}
5
+
6
+ module TopLevelModule {
7
+ module SubModule {
8
+ module DeepSubModule {
9
+ header "deep-submodule.h"
10
+ export *
11
+ }
12
+ module AnotherDeepSubModule {
13
+ header "another-deep-submodule.h"
14
+ export *
15
+ }
16
+ export *
17
+ }
18
+ export *
19
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift -I %S/Inputs -cxx-interoperability-mode=default
2
+ // RUN: %target-typecheck-verify-swift -I %S/Inputs -cxx-interoperability-mode=default -enable-upcoming-feature MemberImportVisibility
3
+ // RUN: %target-typecheck-verify-swift -I %S/Inputs -cxx-interoperability-mode=default -D IMPORT_TOP_LEVEL
4
+ // RUN: %target-typecheck-verify-swift -I %S/Inputs -cxx-interoperability-mode=default -D IMPORT_ANOTHER_SUBMODULE
5
+
6
+ // REQUIRES: swift_feature_MemberImportVisibility
7
+
8
+ #if IMPORT_TOP_LEVEL
9
+ import TopLevelModule
10
+ #elseif IMPORT_ANOTHER_SUBMODULE
11
+ import TopLevelModule. SubModule. AnotherDeepSubModule
12
+ #else
13
+ import TopLevelModule. SubModule. DeepSubModule
14
+ #endif
15
+
16
+ let _: NS . MyStructInDeepSubModule ! = nil
17
+
18
+ extension NS . MyStructInDeepSubModule {
19
+ public static func takesInstance( _ i: NS . MyStructInDeepSubModule ) { }
20
+ }
You can’t perform that action at this time.
0 commit comments