Commit Graph

11 Commits

Author SHA1 Message Date
Egor Zhdan
d4cb7b78d7 [cxx-interop] Add tests for conditional cast to foreign reference type
This is a follow-up to 84ae5fbe.

rdar://141227849
2024-12-17 19:44:19 +00:00
Egor Zhdan
84ae5fbe8c [cxx-interop] Fix runtime crash when casting from an existential to a foreign reference type
When a C++ foreign reference type is conformed to a Swift protocol via a Swift extension, trying to cast `any MyProtocol` to the foreign reference type crashes the runtime.

This was because `selectCasterForDest` wasn't handling C++ foreign reference types, and we were hitting `swift_unreachable`.

This change makes sure the runtime doesn't crash for such casts.

Notably, Swift doesn't have enough metadata to determine if the conditional cast actually succeeded. This is also a problem for CF types. Casting CF types in a similar fashion triggers a typechecker diagnostic. That diagnostic will be amended in a follow-up patch to also trigger for foreign reference types.

rdar://141227849
2024-12-16 20:23:17 +00:00
Egor Zhdan
70b49c983b [cxx-interop] Only run tests for reference types against a recent Swift runtime, pt 2
rdar://128681577
2024-06-11 16:47:44 +01:00
Hamish Knight
3a6f4e04a8 [test] Disable witness-table.swift for arm64e 2024-05-28 21:56:29 +01:00
Egor Zhdan
8f8a242390 [cxx-interop] Fix a test on older macOS versions
This is a test for C++ foreign reference types, which require Swift runtime support that was added in macOS 13.3.

rdar://127991790
2024-05-17 16:09:16 +01:00
Egor Zhdan
961a2e2558 [cxx-interop] Re-enable test for reference types in generic contexts
rdar://95738946
2024-05-08 15:31:26 +01:00
Andrew Trick
b57ceb46cd [nfc] Disable test/Interop/Cxx/foreign-reference/witness-table.swift
Temporarily disable broken test.
2022-06-23 12:58:21 -07:00
zoecarver
96086a0afc [nfc][cxx-interop] Disable FRT test on Windows (not yet supported). 2022-06-16 15:03:15 -07:00
zoecarver
f972f664d3 [cxx-interop] Runtime support for foreign reference types. 2022-06-14 12:18:05 -07:00
zoecarver
839839f924 [cxx-interop] Rename enable-cxx-interop -> enable-experimental-cxx-interop.
Also removes the driver flag, this will now also always be guarded on `-Xfrontend`.
2022-04-07 19:15:25 -07:00
zoecarver
fc3b3a1d71 [cxx-interop] Implement foreign reference types.
This is an expiremental feature to allow an attribute, `import_as_ref`, to import a C++ record as a non-reference-counted reference type in Swift.
2021-12-08 15:35:18 +00:00