Skip to content

🍒[cxx-interop] Do not treat std::pair<UnsafeType, T> as safe #66284

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
Jun 2, 2023

Conversation

egorzhdan
Copy link
Contributor

Explanation: If a C++ types has a copy constructor, we assume that it is safe to use from Swift. Unfortunately this means that types such as std::pair<UnsafeType, T> are treated as safe. This is a larger issue that needs to be addressed, but for now let's make sure we handle std::pair and std::tuple correctly: treat them as safe only if their templated parameters are safe.
Scope: This changes the way Swift imports C++ methods that return std::pair<A, B> where either A or B is unsafe in Swift.
Risk: Low, this only takes effect when C++ interop is enabled.

rdar://109529750
(cherry picked from commit f277158)

rdar://109529750
(cherry picked from commit f277158)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 1, 2023
@egorzhdan egorzhdan requested a review from a team as a code owner June 1, 2023 19:22
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan merged commit 6073432 into release/5.9 Jun 2, 2023
@egorzhdan egorzhdan deleted the egorzhdan/5.9-pair-tuple-unsafe branch June 2, 2023 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants