Skip to content

Commit c56cca1

Browse files
author
Gabor Horvath
committed
[cxx-interop] Do not expose enums with optional generic cases
Unfortunately, we cannot generate the C++ code for them just yet. There will be a follow-up PR to actually fix the underlying issue and expose such enums correctly. rdar://129250756
1 parent fc012fd commit c56cca1

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/PrintAsClang/DeclAndTypePrinter.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2914,6 +2914,9 @@ static bool isEnumExposableToCxx(const ValueDecl *VD,
29142914
if (auto *params = elementDecl->getParameterList()) {
29152915
for (const auto *param : *params) {
29162916
auto paramType = param->getInterfaceType();
2917+
// TODO: properly support exporting these optionals. rdar://131112273
2918+
if (paramType->isOptional() && paramType->getOptionalObjectType()->isTypeParameter())
2919+
return false;
29172920
if (DeclAndTypeClangFunctionPrinter::getTypeRepresentation(
29182921
printer.getTypeMapping(), printer.getInteropContext(),
29192922
printer, enumDecl->getModuleContext(), paramType)

test/Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ public func inoutConcreteOpt(_ x: inout GenericOpt<UInt16>) {
8989
}
9090
}
9191

92+
@frozen public enum GenericCustomType<T> {
93+
case success(T?)
94+
case failure
95+
}
96+
9297
// CHECK: namespace Generics SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("Generics") {
9398

9499
// CHECK: template<class T_0_0>

0 commit comments

Comments
 (0)