Skip to content

[cxx-interop] import static operator call from C++23 as member callAs… #74279

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

Conversation

hyp
Copy link
Contributor

@hyp hyp commented Jun 11, 2024

…Function functions in Swift to preserve source compatibility

@hyp
Copy link
Contributor Author

hyp commented Jun 11, 2024

This is needed to build String.swift in stdlib's CxxStdlib module after MSVC 17.10 update: microsoft/STL@2fa1641#diff-6692e0333a1981f812fabb0a95f0f66c016830e2a7f3f393c990795a8c2d26da , fixes:


S:/SourceCache/swift/stdlib/public/Cxx/std/String.swift:164:49: error: value of type '__swift_interopHashOfString' (aka 'std.hash<basic_string<CChar, char_traits<CChar>, allocator<CChar>>>') has no member 'callAsFunction'
162 |   public func hash(into hasher: inout Hasher) {
163 |     // Call std::hash<std::string>::operator()
164 |     let cxxHash = __swift_interopHashOfString().callAsFunction(self)
    |                                                 `- error: value of type '__swift_interopHashOfString' (aka 'std.hash<basic_string<CChar, char_traits<CChar>, allocator<CChar>>>') has no member 'callAsFunction'
165 |     hasher.combine(cxxHash)
166 |   }

@hyp
Copy link
Contributor Author

hyp commented Jun 11, 2024

@swift-ci please smoke test

@hyp hyp force-pushed the eng/oh-no-msvc-how-can-you-adopt-cxx-23-when-im-not-asking-you-too-sadface-genmoji branch 2 times, most recently from 2f9f722 to 17bbc5a Compare June 11, 2024 17:31
@hyp hyp marked this pull request as ready for review June 11, 2024 17:32
@hyp
Copy link
Contributor Author

hyp commented Jun 11, 2024

@swift-ci please test

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I have a couple comments about tests.

@hyp hyp force-pushed the eng/oh-no-msvc-how-can-you-adopt-cxx-23-when-im-not-asking-you-too-sadface-genmoji branch from 17bbc5a to b38eb67 Compare June 12, 2024 03:48
@hyp
Copy link
Contributor Author

hyp commented Jun 12, 2024

@swift-ci please test

@hyp
Copy link
Contributor Author

hyp commented Jun 12, 2024

@swift-ci please test source compatibility

@egorzhdan egorzhdan requested a review from Xazax-hun June 12, 2024 15:40
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jun 12, 2024
Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for the failing tests, thanks!

…Function functions in Swift to preserve source compatibility
@hyp hyp force-pushed the eng/oh-no-msvc-how-can-you-adopt-cxx-23-when-im-not-asking-you-too-sadface-genmoji branch from b38eb67 to 2039b8d Compare June 12, 2024 16:11
@hyp
Copy link
Contributor Author

hyp commented Jun 12, 2024

@swift-ci please test

@hyp hyp enabled auto-merge June 12, 2024 16:11
@hyp hyp merged commit 5e18474 into swiftlang:main Jun 12, 2024
4 of 5 checks passed
@egorzhdan
Copy link
Contributor

Looks like this is failing with an assertion in rebranch:

Assertion failed: (isInstance() && "No 'this' for static methods!"), function getThisType, file DeclCXX.cpp, line 2598.

https://ci.swift.org/view/Swift%20rebranch/job/oss-swift-rebranch-incremental-RA-macos/4764/

@egorzhdan
Copy link
Contributor

Here's a PR with the fix for rebranch: #75907

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