mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[cxx-interop] Fix assert failure exporting C++ types to Obj-C
This is not supported, of course. But now, instead of an assertion failure we properly mark the declaration as unavailable. Fixes #78190. rdar://141492654
This commit is contained in:
@@ -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
|
||||
|
||||
5
test/Interop/CxxToSwiftToObjC/Inputs/cxxmodule.h
Normal file
5
test/Interop/CxxToSwiftToObjC/Inputs/cxxmodule.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
struct Foo {
|
||||
void *foo;
|
||||
};
|
||||
5
test/Interop/CxxToSwiftToObjC/Inputs/module.modulemap
Normal file
5
test/Interop/CxxToSwiftToObjC/Inputs/module.modulemap
Normal file
@@ -0,0 +1,5 @@
|
||||
module CxxModule [system] {
|
||||
header "cxxmodule.h"
|
||||
requires cplusplus
|
||||
export *
|
||||
}
|
||||
11
test/Interop/CxxToSwiftToObjC/bridge-cxx-types-to-objc.swift
Normal file
11
test/Interop/CxxToSwiftToObjC/bridge-cxx-types-to-objc.swift
Normal file
@@ -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.
|
||||
Reference in New Issue
Block a user