Skip to content

[cxx-interop] Fix assert failure exporting C++ types to Obj-C #78219

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
Dec 18, 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
2 changes: 1 addition & 1 deletion lib/PrintAsClang/PrintClangFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ ClangRepresentation DeclAndTypeClangFunctionPrinter::printFunctionSignature(
interopContext, CFunctionSignatureTypePrinterModifierDelegate(),
emittedModule, declPrinter);
auto s = typePrinter.visit(ty, optionalKind, param.isInOut());
assert(!s.isUnsupported());
resultingRepresentation.merge(s);
};
signature.visitParameterList(
[&](const LoweredFunctionSignature::IndirectResultValue
Expand Down
5 changes: 5 additions & 0 deletions test/Interop/CxxToSwiftToObjC/Inputs/cxxmodule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#pragma once

struct Foo {
void *foo;
};
5 changes: 5 additions & 0 deletions test/Interop/CxxToSwiftToObjC/Inputs/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module CxxModule [system] {
header "cxxmodule.h"
requires cplusplus
export *
}
11 changes: 11 additions & 0 deletions test/Interop/CxxToSwiftToObjC/bridge-cxx-types-to-objc.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %empty-directory(%t)

// RUN: %target-swift-frontend -typecheck %s -module-name UseCxxModule -emit-objc-header -emit-objc-header-path %t/UseCxxTy.h -I %t -I %S/Inputs -clang-header-expose-decls=all-public -cxx-interoperability-mode=default
// RUN: %FileCheck %s < %t/UseCxxTy.h

import CxxModule

public func bar(x: Foo, y: UnsafeMutablePointer<UnsafeMutableRawPointer?>) {}

// CHECK: // Unavailable in C++: Swift global function 'bar(x:y:)'.
// TODO: the message above is not correct, this is actually unavailable in Obj-C.