File tree Expand file tree Collapse file tree 5 files changed +45
-3
lines changed Expand file tree Collapse file tree 5 files changed +45
-3
lines changed Original file line number Diff line number Diff line change @@ -2808,7 +2808,7 @@ namespace {
2808
2808
// If this module is declared as a C++ module, try to synthesize
2809
2809
// conformances to Swift protocols from the Cxx module.
2810
2810
auto clangModule = Impl.getClangOwningModule (result->getClangNode ());
2811
- if (clangModule && requiresCPlusPlus (clangModule)) {
2811
+ if (! clangModule || requiresCPlusPlus (clangModule)) {
2812
2812
if (auto nominalDecl = dyn_cast<NominalTypeDecl>(result)) {
2813
2813
conformToCxxIteratorIfNeeded (Impl, nominalDecl, decl);
2814
2814
conformToCxxSequenceIfNeeded (Impl, nominalDecl, decl);
Original file line number Diff line number Diff line change @@ -17,4 +17,9 @@ class VectorSubclass: public Vector {
17
17
public:
18
18
};
19
19
20
+ class VectorOfStringSubclass : public std ::vector<std::string> {
21
+ public:
22
+ using std::vector<std::string>::vector;
23
+ };
24
+
20
25
#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_VECTOR_H
Original file line number Diff line number Diff line change 1
1
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
2
2
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
3
- //
3
+
4
+ // Also test this with a bridging header instead of the StdMap module.
5
+ // RUN: %empty-directory(%t2)
6
+ // RUN: cp %S/Inputs/std-map.h %t2/std-map-bridging-header.h
7
+ // RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-map-bridging-header.h -Xfrontend -enable-experimental-cxx-interop)
8
+ // RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-map-bridging-header.h -cxx-interoperability-mode=upcoming-swift)
9
+
4
10
// REQUIRES: executable_test
5
11
//
6
12
// REQUIRES: OS=macosx || OS=linux-gnu
7
13
8
14
import StdlibUnittest
15
+ #if !BRIDGING_HEADER
9
16
import StdMap
17
+ #endif
10
18
import CxxStdlib
11
19
import Cxx
12
20
Original file line number Diff line number Diff line change 1
1
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
2
2
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
3
- //
3
+
4
+ // Also test this with a bridging header instead of the StdSet module.
5
+ // RUN: %empty-directory(%t2)
6
+ // RUN: cp %S/Inputs/std-set.h %t2/std-set-bridging-header.h
7
+ // RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-set-bridging-header.h -Xfrontend -enable-experimental-cxx-interop)
8
+ // RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-set-bridging-header.h -cxx-interoperability-mode=upcoming-swift)
9
+
4
10
// REQUIRES: executable_test
5
11
//
6
12
// Enable this everywhere once we have a solution for modularizing other C++ stdlibs: rdar://87654514
7
13
// REQUIRES: OS=macosx || OS=linux-gnu
8
14
9
15
import StdlibUnittest
16
+ #if !BRIDGING_HEADER
10
17
import StdSet
18
+ #endif
11
19
import CxxStdlib
12
20
import Cxx
13
21
Original file line number Diff line number Diff line change 1
1
// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
2
2
// RUN: %target-run-simple-swift(-I %S/Inputs -cxx-interoperability-mode=upcoming-swift)
3
+
4
+ // Also test this with a bridging header instead of the StdVector module.
5
+ // RUN: %empty-directory(%t2)
6
+ // RUN: cp %S/Inputs/std-vector.h %t2/std-vector-bridging-header.h
7
+ // RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-vector-bridging-header.h -Xfrontend -enable-experimental-cxx-interop)
8
+ // RUN: %target-run-simple-swift(-D BRIDGING_HEADER -import-objc-header %t2/std-vector-bridging-header.h -cxx-interoperability-mode=upcoming-swift)
9
+
3
10
// FIXME: also run in C++20 mode when conformance works properly on UBI platform (rdar://109366764):
4
11
// %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -std=gnu++20)
5
12
//
6
13
// REQUIRES: executable_test
7
14
8
15
import StdlibUnittest
16
+ #if !BRIDGING_HEADER
9
17
import StdVector
18
+ #endif
10
19
import CxxStdlib
11
20
12
21
var StdVectorTestSuite = TestSuite ( " StdVector " )
@@ -132,4 +141,16 @@ StdVectorTestSuite.test("VectorOfInt subclass for loop") {
132
141
expectEqual ( count, 2 )
133
142
}
134
143
144
+ StdVectorTestSuite . test ( " VectorOfString subclass for loop " ) {
145
+ var v = VectorOfStringSubclass ( )
146
+ v. push_back ( std. string ( " abc " ) )
147
+
148
+ var count : CInt = 0
149
+ for e in v {
150
+ expectEqual ( std. string ( " abc " ) , e)
151
+ count += 1
152
+ }
153
+ expectEqual ( count, 1 )
154
+ }
155
+
135
156
runAllTests ( )
You can’t perform that action at this time.
0 commit comments