File tree Expand file tree Collapse file tree 5 files changed +39
-0
lines changed
test/ClangImporter/MixedSource
Inputs/defer-supermodule-import Expand file tree Collapse file tree 5 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ #import < Some/Submodule.h>
2
+
3
+ @interface Thing
4
+ + (void )fn : (KLASS*)arg ;
5
+ @end
6
+
7
+ void bar (TYPE t);
Original file line number Diff line number Diff line change
1
+ typedef int TYPE;
2
+ @class KLASS;
Original file line number Diff line number Diff line change
1
+ int foo ();
Original file line number Diff line number Diff line change
1
+ framework module Some {
2
+ header "Some.h"
3
+ export *
4
+ module Submodule {
5
+ header "Submodule.h"
6
+ export *
7
+ }
8
+ }
Original file line number Diff line number Diff line change
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 ( ) ) )
You can’t perform that action at this time.
0 commit comments