Skip to content

Commit 32bad62

Browse files
authored
Merge pull request #72129 from artemcm/canImportSubmoduleInfer
On 'canImport' of Clang submodules of modules with an umbrella header, attempt to infer the submodule
2 parents 4c58f50 + 0808a1d commit 32bad62

File tree

5 files changed

+22
-1
lines changed

5 files changed

+22
-1
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2064,7 +2064,7 @@ bool ClangImporter::canImportModule(ImportPath::Module modulePath,
20642064

20652065
if (modulePath.hasSubmodule()) {
20662066
for (auto &component : modulePath.getSubmodulePath()) {
2067-
clangModule = clangModule->findSubmodule(component.Item.str());
2067+
clangModule = clangModule->findOrInferSubmodule(component.Item.str());
20682068

20692069
// Special case: a submodule named "Foo.Private" can be moved to a
20702070
// top-level module named "Foo_Private". Clang has special support for
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void funcInferred(void);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#import <WithInferredClangModule/InferredClangModule.h>
2+
void funcWith(void);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework module WithInferredClangModule [system] {
2+
header "WithInferredClangModule.h"
3+
umbrella "Headers"
4+
5+
export *
6+
explicit module * { export * }
7+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// REQUIRES: OS=macosx
2+
// RUN: %empty-directory(%t)
3+
// RUN: %target-swift-frontend -scan-dependencies %s -o %t/deps.json -disable-implicit-concurrency-module-import -disable-implicit-string-processing-module-import -F %S/Inputs/Frameworks
4+
// RUN: %validate-json %t/deps.json | %FileCheck %s
5+
6+
#if canImport(WithInferredClangModule.InferredClangModule)
7+
import ScannerTestKit
8+
#endif
9+
10+
// Ensure that the 'WithInferredClangModule.InferredClangModule' can be imported
11+
// CHECK: "swift": "ScannerTestKit"

0 commit comments

Comments
 (0)