Skip to content

Commit 72dbff3

Browse files
author
Gabor Horvath
committed
🍒[6.1][cxx-interop] Avoid spurious type aliases in reverse interop
Explanation: Due to a missing check we emitted using declarations for types we did not emit into the reverse interop header resulted in compilation errors. Scope: C++ reverse interop Risk: Low. The fix is straightforward calling a function to do the check if the entity should be included in the reverse interop header. It does not affect other code paths. Testing: Added compiler tests. Issue: rdar://141688074 Reviewer: @egorzhdan Original PR: #78287
1 parent 38a990a commit 72dbff3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 3 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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)