[cxx-interop] Support types nested in extensions

The generated header did not compile due to a bug that prevented us from
referencing the correct namespaces derived from the nominal type's name
(an extension does not have a name). Moreover, we did not generate
forward declarations for the members of the extensions for classes and
enums (but we did for structs). This change also removes a workaround
that emitted String::Index as _String_Index.

rdar://153221450
This commit is contained in:
Gabor Horvath
2025-07-02 11:25:39 +01:00
parent 2113752b00
commit c5b18a0a9e
5 changed files with 42 additions and 20 deletions

View File

@@ -767,6 +767,10 @@ public:
return false;
(void)forwardDeclareMemberTypes(CD->getAllMembers(), CD);
for (const auto *ed :
printer.getInteropContext().getExtensionsForNominalType(CD)) {
(void)forwardDeclareMemberTypes(ed->getAllMembers(), CD);
}
auto [it, inserted] =
seenTypes.try_emplace(CD, EmissionState::NotYetDefined, false);
if (outputLangMode == OutputLanguageMode::Cxx &&
@@ -868,6 +872,10 @@ public:
if (outputLangMode == OutputLanguageMode::Cxx) {
forwardDeclareMemberTypes(ED->getAllMembers(), ED);
for (const auto *ed :
printer.getInteropContext().getExtensionsForNominalType(ED)) {
(void)forwardDeclareMemberTypes(ed->getAllMembers(), ED);
}
forwardDeclareCxxValueTypeIfNeeded(ED);
}