Skip to content

Commit 0eab959

Browse files
author
Gabor Horvath
committed
[cxx-interop] Do not export enums with indirect associated values
We do not support any sort of indirect enums yet, the code gets into an infinite recursion. Let's skip exporting these types to C++ for now until proper support is implemented. rdar://134852756
1 parent f6791a2 commit 0eab959

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/AST/SwiftNameTranslation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ swift::cxx_translation::getDeclRepresentation(const ValueDecl *VD) {
264264
for (const auto *elementDecl : enumCase->getElements()) {
265265
if (!elementDecl->hasAssociatedValues())
266266
continue;
267+
if (elementDecl->isIndirect())
268+
return {Unsupported, UnrepresentableIndirectEnum};
267269
// Do not expose any enums with > 1
268270
// enum parameter, or any enum parameter
269271
// whose type we do not yet support.

test/Interop/SwiftToCxx/enums/swift-enum-implementation.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public enum E2 {
3333
case baz
3434
}
3535

36+
public enum Expr {
37+
case Const(Int)
38+
indirect case Neg(Expr)
39+
}
40+
3641
public struct S {
3742
public var x: Int64
3843

0 commit comments

Comments
 (0)