swift
swift copied to clipboard
[cxx-interop] C++ Tuples in `*-Swift.h` wrongfully have an extraneous angled brackets (`std::tuple<<double>>` vs `std::tuple<double>`)
Description
In the generated -Swift.h header, Swift properly parses C++ types such as std::vector<T>:
+ SWIFT_INLINE_THUNK std::__1::vector<double, std::allocator<double>> getNumbers() SWIFT_SYMBOL("s:10NitroImage34HybridSwiftKotlinTestObjectSpecCxxC10getNumbersSo3stdO3__1O0044vectorCDoubleallocatorCDouble_xDFGkvkyqsaJeaVyF");
..however when using an std::tuple, it accidentally generates one template angled brackets too many (std::tuple<<..>> instead of std::tuple<..>):
- SWIFT_INLINE_THUNK std::__1::tuple<<double, double, std::string>> getTuple() SWIFT_SYMBOL("s:10NitroImage34HybridSwiftKotlinTestObjectSpecCxxC8getTupleSo3stdO3__1O0014tuple__AuJCaraVyF");
^ ❌
..which causes the build to fail.
Reproduction
// specializations as templates cannot be used in swift yet
using std__vector_double_ = std::vector<double>;
using std__tuple_double__double__std__string_ = std::tuple<double, double, std::string>;
func getNumbers() -> std__vector_double_ {
return helpers.create_std__vector_double_()
}
func getTuple() -> std__tuple_double__double__std__string_ {
return helpers. std__tuple_double__double__std__string_()
}
Expected behavior
I expect the tuple to be properly generated in the -Swift.h header, like so:
SWIFT_INLINE_THUNK std::__1::tuple<double, double, std::string> getTuple() SWIFT_SYMBOL("s:10NitroImage34HybridSwiftKotlinTestObjectSpecCxxC8getTupleSo3stdO3__1O0014tuple__AuJCaraVyF");
Environment
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-macosx14.0
Additional information
No response
Same goes for std::variant<A, B> btw:
SWIFT_INLINE_THUNK std::__1::variant<<std::string, double>> HybridSwiftKotlinTestObjectSpecCxx::getSomeVariant() {