Skip to content

Commit 416a12e

Browse files
committed
[Clang Importer] Test for deferred module imports, rdar://30615193
1 parent 2a8fd72 commit 416a12e

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#import <Some/Submodule.h>
2+
3+
@interface Thing
4+
+ (void)fn:(KLASS*)arg;
5+
@end
6+
7+
void bar(TYPE t);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
typedef int TYPE;
2+
@class KLASS;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
int foo();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
framework module Some {
2+
header "Some.h"
3+
export *
4+
module Submodule {
5+
header "Submodule.h"
6+
export *
7+
}
8+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: not %target-swift-frontend -F %S/Inputs/defer-supermodule-import -import-objc-header %S/Inputs/defer-supermodule-import/Some-Bridging-Header.h -typecheck %s 2>&1 | %FileCheck -check-prefix=HEADER-ERROR %s
2+
// HEADER-ERROR: Some-Bridging-Header.h:4:13: error: expected a type
3+
// HEADER-ERROR: Some-Bridging-Header.h:7:10: error: declaration of 'TYPE' must be imported from module 'Some' before it is required
4+
// REQUIRES: objc_interop
5+
6+
// The bug we're testing here is that:
7+
//
8+
// - Given a supermodule defining some types
9+
// - Given a submodule of that supermodule
10+
// - Given an _erroneous_ bridging header that imports the _submodule_ and tries
11+
// to use the _supermodule's_ types
12+
//
13+
// That we emit an error. Previously we did not: Swift's "implicit supermodule
14+
// import" rule would fire _eagerly_, so by the time the submodule import was
15+
// complete the supermodule was also imported and the bridging header would pass
16+
// through without flagging the error. This made it possible to write textual
17+
// bridging headers that would not, themselves, be considered valid objc code as
18+
// far as clang (or more importantly: clang's PCH-generating pass) was
19+
// concerned.
20+
21+
print(bar(foo()))

0 commit comments

Comments
 (0)