mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When importing C++ class template instantiations, Swift generates a type name for each instantiation. The generated names must be unique, since they are used for mangling. If multiple different C++ types declare nested types with the same name, which are then used as template arguments, Swift was generating the same name for those template instantiations (e.g. `shared_ptr<Impl>` for different `Impl` types). This change makes sure we use fully-qualified type names of template parameters when generating Swift type names for class template instantiations (e.g. `shared_ptr<MyNamespace.MyClass.Impl>`). This fixes an assertion failure coming out of IRGen: ``` Assertion failed: (Buffer.empty() && "didn't claim all values out of buffer"), function ~ConstantInitBuilderBase, file ConstantInitBuilder.h, line 75. ``` rdar://141962480
32 lines
653 B
C++
32 lines
653 B
C++
#ifndef TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_H
|
|
#define TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_H
|
|
|
|
namespace Space {
|
|
|
|
template <class...> struct Ship;
|
|
template <class T, class... Args> struct Ship<T(Args...)> {};
|
|
|
|
using Orbiter = Ship<void(bool)>;
|
|
|
|
template <class T>
|
|
struct Box {
|
|
T value;
|
|
};
|
|
|
|
using IntBoxWithinNS = Box<int>;
|
|
using BoxOfIntBoxWithinNS = Box<Box<int>>;
|
|
|
|
namespace NestedNS1 {
|
|
struct Impl {};
|
|
using ImplBox1 = Box<Impl>;
|
|
}
|
|
|
|
namespace NestedNS2 {
|
|
struct Impl {};
|
|
using ImplBox2 = Box<Impl>;
|
|
}
|
|
|
|
} // namespace Space
|
|
|
|
#endif // TEST_INTEROP_CXX_TEMPLATES_INPUTS_CLASS_TEMPLATE_IN_NAMESPACE_H
|