mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user