Skip to content

[cxx-interop] Do not expose enums with optional generic cases #74966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/PrintAsClang/DeclAndTypePrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2914,6 +2914,9 @@ static bool isEnumExposableToCxx(const ValueDecl *VD,
if (auto *params = elementDecl->getParameterList()) {
for (const auto *param : *params) {
auto paramType = param->getInterfaceType();
// TODO: properly support exporting these optionals. rdar://131112273
if (paramType->isOptional() && paramType->getOptionalObjectType()->isTypeParameter())
return false;
if (DeclAndTypeClangFunctionPrinter::getTypeRepresentation(
printer.getTypeMapping(), printer.getInteropContext(),
printer, enumDecl->getModuleContext(), paramType)
Expand Down
5 changes: 5 additions & 0 deletions test/Interop/SwiftToCxx/generics/generic-enum-in-cxx.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ public func inoutConcreteOpt(_ x: inout GenericOpt<UInt16>) {
}
}

@frozen public enum GenericCustomType<T> {
case success(T?)
case failure
}

// CHECK: namespace Generics SWIFT_PRIVATE_ATTR SWIFT_SYMBOL_MODULE("Generics") {

// CHECK: template<class T_0_0>
Expand Down