Skip to content

🍒 [6.2] [cxx-interop] Allow C++ function templates to be instantiated with Swift closures #81214

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

Conversation

j-hui
Copy link
Contributor

@j-hui j-hui commented Apr 30, 2025

Explanation: This patch relaxes the convertTemplateArgument() function to also allow instantiating function templates with Swift closures, which was possible earlier to but incorrectly diagnosed as an error since #77430.

This PR omits an [NFC] patch that converts a Boolean flag into a template argument.

Issue: rdar://148124104
Risk: low
Testing: added tests
Original PRs: #81016
Reviewer: @Xazax-hun

…ift closures

Swift started to explicitly forbid the instantiation of C++ function
templates with arbitrary types in swiftlang#77430, because many types cause the
Swift compiler to crash. However, those checks prevented them from being
instantiated with Swift closures (which were previously fine), causing
a regression.

This patch relaxes the convertTemplateArgument() function to also allow
converting Swift function types, and adds some tests to make sure doing
so is fine.

This patch also does some cleanup of existing tests checking the
instantiation of various types, and adds testing for C function pointers
and Obj-C blocks.

rdar://148124104
(cherry picked from commit 284de98)
@j-hui j-hui requested a review from a team as a code owner April 30, 2025 20:53
@j-hui
Copy link
Contributor Author

j-hui commented Apr 30, 2025

@swift-ci please test

@j-hui
Copy link
Contributor Author

j-hui commented May 1, 2025

@swift-ci please test macos

@j-hui j-hui force-pushed the base-6.2/swift-function-as-template-arg branch from 15ffc80 to 3f8e9cd Compare May 7, 2025 00:20
@j-hui
Copy link
Contributor Author

j-hui commented May 7, 2025

@swift-ci please test

@j-hui j-hui enabled auto-merge May 7, 2025 06:23
@j-hui j-hui merged commit 1459eca into swiftlang:release/6.2 May 7, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants