Skip to content

[cxx-interop] import static operator call from C++23 as member callAsFunction functions in Swift to preserve source compatibility #76619

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 3 commits into from
Sep 21, 2024

Conversation

compnerd
Copy link
Member

No description provided.

hyp and others added 3 commits September 20, 2024 15:07
…Function functions in Swift to preserve source compatibility
This fixes an assertion failure:
```
Assertion failed: (isInstance() && "No 'this' for static methods!"), function getThisType, file DeclCXX.cpp, line 2636.
```

Clang changed it's handling of member call expressions in llvm/llvm-project@af47517 causing the assertion to fail when synthesizing a forwarding function declaration for `static operator()`.

rdar://133257179
@compnerd compnerd requested a review from a team as a code owner September 20, 2024 22:08
@compnerd
Copy link
Member Author

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Sep 20, 2024

Explanation: The C++ standard library included in recent versions of Microsoft Visual Studio have adopted a C++23 feature "static operator()", which causes a source compatibility break for Swift/C++ interoperability on Windows. Implement support for static operator() in the Clang importer by importing it as an instance method callAsFunction. This ensures that the source-compatible change to C++23 code (from operator() to static operator()) will also be a source-compatible change for Swift/C++ interoperability.
Issue: compnerd/swift-build#808
Scope: This is a general addition to the Clang importer for C++ interoperability, although it's applicability is very narrow: static operator() is a new feature in C++23, and is not yet widely used.
Risk: Since static operator() is so new in C++23, and this fix is narrowly targeted at importing that feature, the likelihood of this affecting anything else is small.
Testing: CI, new tests
Reviewed By: @egorzhdan, @DougGregor
Original PR: #74279

@shahmishal shahmishal merged commit 37c589e into swiftlang:release/6.0.0 Sep 21, 2024
5 checks passed
@compnerd compnerd deleted the 600-calls branch September 22, 2024 15:26
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.

5 participants