Skip to content

Commit 0808a1d

Browse files
committed
On 'canImport' of Clang submodules of modules with an umbrella header, attempt to infer the submodule
Resolves rdar://124163264
1 parent 1752b48 commit 0808a1d

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
@@ -2039,7 +2039,7 @@ bool ClangImporter::canImportModule(ImportPath::Module modulePath,
20392039

20402040
if (modulePath.hasSubmodule()) {
20412041
for (auto &component : modulePath.getSubmodulePath()) {
2042-
clangModule = clangModule->findSubmodule(component.Item.str());
2042+
clangModule = clangModule->findOrInferSubmodule(component.Item.str());
20432043

20442044
// Special case: a submodule named "Foo.Private" can be moved to a
20452045
// 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)