Skip to content

Commit 8a3beca

Browse files
author
Gabor Horvath
committed
[cxx-interop] Avoid spurious type aliases in reverse interop
To support nested structs, we emit type aliases in the outer class. Unfortunately, we emitted these type aliases unconditionally, even if the actualy nested struct was not emitted to the reverse interop header (due to visibility or the construct being unsupported). This PR fixed this issue by checking first if the nested entity should be included in the reverse interop header. rdar://141688074
1 parent 568fa14 commit 8a3beca

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,9 @@ class DeclAndTypePrinter::Implementation
257257
for (const Decl *member : members) {
258258
if (member->getModuleContext()->isStdlibModule())
259259
break;
260+
auto VD = dyn_cast<ValueDecl>(member);
261+
if (!VD || !shouldInclude(VD))
262+
continue;
260263
// TODO: support nested classes.
261264
if (isa<ClassDecl>(member))
262265
continue;

test/Interop/SwiftToCxx/structs/nested-structs-in-cxx.swift

+6
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,9 @@ public func makeRecordConfig() -> RecordConfig {
6060
public func makeAudioFileType() -> AudioFileType {
6161
return AudioFileType.CAF(AudioFileType.SubType(id: 42))
6262
}
63+
64+
public class TestObject {
65+
enum CustomError: Swift.Error {
66+
case invalid
67+
}
68+
}

0 commit comments

Comments
 (0)