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 {
28082808 // If this module is declared as a C++ module, try to synthesize
28092809 // conformances to Swift protocols from the Cxx module.
28102810 auto clangModule = Impl.getClangOwningModule (result->getClangNode ());
2811- if (clangModule && requiresCPlusPlus (clangModule)) {
2811+ if (! clangModule || requiresCPlusPlus (clangModule)) {
28122812 if (auto nominalDecl = dyn_cast<NominalTypeDecl>(result)) {
28132813 conformToCxxIteratorIfNeeded (Impl, nominalDecl, decl);
28142814 conformToCxxSequenceIfNeeded (Impl, nominalDecl, decl);
Original file line number Diff line number Diff line change @@ -17,4 +17,9 @@ class VectorSubclass: public Vector {
1717public:
1818};
1919
20+ class VectorOfStringSubclass : public std ::vector<std::string> {
21+ public:
22+ using std::vector<std::string>::vector;
23+ };
24+
2025#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_STD_VECTOR_H
Original file line number Diff line number Diff line change 11// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22// 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+
410// REQUIRES: executable_test
511//
612// REQUIRES: OS=macosx || OS=linux-gnu
713
814import StdlibUnittest
15+ #if !BRIDGING_HEADER
916import StdMap
17+ #endif
1018import CxxStdlib
1119import Cxx
1220
Original file line number Diff line number Diff line change 11// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22// 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+
410// REQUIRES: executable_test
511//
612// Enable this everywhere once we have a solution for modularizing other C++ stdlibs: rdar://87654514
713// REQUIRES: OS=macosx || OS=linux-gnu
814
915import StdlibUnittest
16+ #if !BRIDGING_HEADER
1017import StdSet
18+ #endif
1119import CxxStdlib
1220import Cxx
1321
Original file line number Diff line number Diff line change 11// RUN: %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop)
22// 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+
310// FIXME: also run in C++20 mode when conformance works properly on UBI platform (rdar://109366764):
411// %target-run-simple-swift(-I %S/Inputs -Xfrontend -enable-experimental-cxx-interop -Xcc -std=gnu++20)
512//
613// REQUIRES: executable_test
714
815import StdlibUnittest
16+ #if !BRIDGING_HEADER
917import StdVector
18+ #endif
1019import CxxStdlib
1120
1221var StdVectorTestSuite = TestSuite ( " StdVector " )
@@ -132,4 +141,16 @@ StdVectorTestSuite.test("VectorOfInt subclass for loop") {
132141 expectEqual ( count, 2 )
133142}
134143
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+
135156runAllTests ( )
You can’t perform that action at this time.
0 commit comments