[cxx-interop] Fix unavailable generics triggering compilation error

In some cases, the reverse interop generated both a forward declaration and a
definition with unavailable attribute in the C++ header. Unfortunately, the
kinds of these symbol did not match. The forward declaration was templated
while the definition was not. The forward declaration has the correct kind,
so this patch extends the printing of unavailable definitions to include the
generic arguments.

rdar://119835933
This commit is contained in:
Gabor Horvath
2024-06-11 11:43:02 +01:00
parent 382a8e7653
commit 353f0608f9
2 changed files with 50 additions and 1 deletions

View File

@@ -874,6 +874,11 @@ public:
// Emit an unavailable stub for a Swift type.
if (auto *nmtd = dyn_cast<NominalTypeDecl>(vd)) {
auto representation = cxx_translation::getDeclRepresentation(vd);
if (nmtd->isGeneric()) {
auto genericSignature =
nmtd->getGenericSignature().getCanonicalSignature();
ClangSyntaxPrinter(os).printGenericSignature(genericSignature);
}
os << "class ";
ClangSyntaxPrinter(os).printBaseName(vd);
os << " { } SWIFT_UNAVAILABLE_MSG(\"";