Skip to content

Commit cde0ce7

Browse files
committed
Add test for canImport submodule in mixed framework
1 parent 1f77f46 commit cde0ce7

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

test/ClangImporter/MixedSource/Inputs/WithSubmodule.framework/Empty.swift

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int fromSubmodule;

test/ClangImporter/MixedSource/Inputs/WithSubmodule.framework/Modules/WithSubmodule.swiftmodule/.keep

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
framework module WithSubmodule {
2+
explicit module Submodule {
3+
header "Submodule.h"
4+
export *
5+
}
6+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: cp -r %S/Inputs/WithSubmodule.framework %t
3+
// RUN: %target-swift-frontend -emit-module -o %t/WithSubmodule.framework/Modules/WithSubmodule.swiftmodule/%target-swiftmodule-name %t/WithSubmodule.framework/Empty.swift -import-underlying-module -F %t -module-name WithSubmodule
4+
5+
// RUN: %target-typecheck-verify-swift -F %t
6+
7+
// Testing 'canImport()' non-existing submodule in a top module loadable by other loaders.
8+
9+
#if !canImport(WithSubmodule.Submodule)
10+
#error("Should can import WithSubmodule.Submodule")
11+
#endif
12+
13+
// Should fail if checked for a non-existing submodule.
14+
#if canImport(WithSubmodule.ButNotMe)
15+
import WithSubmodule.Submodule
16+
#endif
17+
18+
func testNotImported() {
19+
fromSubmodule = 5
20+
// expected-error@-1 {{cannot find 'fromSubmodule' in scope}}
21+
}

0 commit comments

Comments
 (0)