File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
test/Interop/SwiftToCxx/stdlib Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -622,7 +622,8 @@ static bool isOptionalForeignReferenceType(Type ty) {
622622 if (auto obj = ty->getOptionalObjectType ()) {
623623 if (const auto *cd =
624624 dyn_cast_or_null<ClassDecl>(obj->getNominalOrBoundGenericNominal ()))
625- return cd->isForeignReferenceType ();
625+ return cd->isForeignReferenceType () ||
626+ cd->getForeignClassKind () == ClassDecl::ForeignKind::CFType;
626627 }
627628 return false ;
628629}
@@ -1780,7 +1781,8 @@ bool DeclAndTypeClangFunctionPrinter::hasKnownOptionalNullableCxxMapping(
17801781 return typeInfo->canBeNullable ;
17811782 }
17821783 if (const auto *cd = dyn_cast<ClassDecl>(nominal))
1783- if (cd->isForeignReferenceType ())
1784+ if (cd->isForeignReferenceType () ||
1785+ cd->getForeignClassKind () == ClassDecl::ForeignKind::CFType)
17841786 return true ;
17851787 return isa_and_nonnull<clang::ObjCInterfaceDecl>(nominal->getClangDecl ());
17861788 }
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ public func foobar(_ a: CFData) -> Bool {
1616 true
1717}
1818
19+ public func returnsCFDate( ) -> CFDate ? {
20+ nil
21+ }
22+
23+ public func takesCFDate( x: CFDate ? ) { }
24+
1925public func networkThing( ) -> in_addr ? {
2026 return nil
2127}
@@ -25,4 +31,9 @@ public enum MyEnum {
2531}
2632
2733// CHECK: SWIFT_EXTERN bool $s17UseCoreFoundation6foobarySbSo9CFDataRefaF(CFDataRef _Nonnull a) SWIFT_NOEXCEPT SWIFT_CALL; // foobar(_:)
34+ // CHECK: SWIFT_EXTERN CFDateRef _Nullable $s17UseCoreFoundation13returnsCFDateSo0E3RefaSgyF(void) SWIFT_NOEXCEPT SWIFT_CALL; // returnsCFDate()
35+ // CHECK: SWIFT_EXTERN void $s17UseCoreFoundation11takesCFDate1xySo0E3RefaSg_tF(CFDateRef _Nullable x) SWIFT_NOEXCEPT SWIFT_CALL; // takesCFDate(x:)
36+
2837// CHECK: SWIFT_INLINE_THUNK swift::Optional<in_addr> networkThing() noexcept SWIFT_SYMBOL("s:17UseCoreFoundation12networkThingSo7in_addrVSgyF") SWIFT_WARN_UNUSED_RESULT {
38+ // CHECK: SWIFT_INLINE_THUNK CFDateRef _Nullable returnsCFDate() noexcept SWIFT_SYMBOL("s:17UseCoreFoundation13returnsCFDateSo0E3RefaSgyF") SWIFT_WARN_UNUSED_RESULT {
39+ // CHECK: SWIFT_INLINE_THUNK void takesCFDate(CFDateRef _Nullable x) noexcept SWIFT_SYMBOL("s:17UseCoreFoundation11takesCFDate1xySo0E3RefaSg_tF") {
You can’t perform that action at this time.
0 commit comments