Skip to content

🍒[cxx-interop] Fix generated header for Swift closures using CF_OPTIONS types #82723

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
Jul 2, 2025

Conversation

egorzhdan
Copy link
Contributor

@egorzhdan egorzhdan commented Jul 2, 2025

  • Explanation: If a Swift class has a field, which has a closure type, which takes an instance of a CF_OPTIONS/NS_OPTIONS type as a parameter, the reverse interop logic would generate an invalid Objective-C++ header for such type. This was discovered with UIKit's UIControlState type, which is declared with NS_OPTIONS in Objective-C, then renamed to UIControl.State with API Notes, and then re-exported to Objective-C++ via the generated header.
  • Scope: This changes the decl name translation logic from Swift into Objective-C++.
  • Issues: rdar://129622886
  • Original PRs: [cxx-interop] Fix generated header for Swift closures using CF_OPTIONS types #82691
  • Risk: Low, this only takes effect for CF_OPTIONS types which were previously mishandled.
  • Testing: Added a compiler test.
  • Reviewers: @Xazax-hun

…NS` types

If a Swift class has a field, which has a closure type, which takes an instance of a `CF_OPTIONS`/`NS_OPTIONS` type as a parameter, the reverse interop logic would generate an invalid Objective-C++ header for such type.

This was discovered with UIKit's `UIControlState` type, which is declared with `NS_OPTIONS` in Objective-C, then renamed to `UIControl.State` with API Notes, and then re-exported to Objective-C++ via the generated header.

rdar://129622886

(cherry picked from commit e95c9ec)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jul 2, 2025
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan marked this pull request as ready for review July 2, 2025 14:15
@egorzhdan egorzhdan requested a review from a team as a code owner July 2, 2025 14:15
@egorzhdan egorzhdan enabled auto-merge July 2, 2025 21:47
@egorzhdan egorzhdan merged commit 40c4f3c into release/6.2 Jul 2, 2025
5 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/6.2-cfoptions-block-param branch July 2, 2025 22:54
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.

3 participants