Skip to content

[🍒][nfc][cxx-interop] Update tests for mutable struct fields #66672

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

zoecarver
Copy link
Contributor

@zoecarver zoecarver commented Jun 15, 2023

Explanation: Methods that are marked as const in C++ can still modify a field of the object if the field is marked as mutable. We previously imported all methods of structs with mutable fields as mutating in Swift. Unfortunately this doesn't work well with libstdc++, which uses mutable fields for some commonly used container types. Our current user model assumes that we trust the const keyword on a C++ method, and import them as non-mutating in Swift. Let's make sure the tests reflect that.

Scope: C++ interoperability test
Risk: None: this is a test-only change.
Testing: Swift unit tests.
PR: #64877

Methods that are marked as `const` in C++ can still modify a field of the object if the field is marked as `mutable`.

We previously imported all methods of structs with mutable fields as mutating in Swift. Unfortunately this doesn't work well with libstdc++, which uses mutable fields for some commonly used container types.

Our current user model assumes that we trust the `const` keyword on a C++ method, and import them as non-mutating in Swift. Let's make sure the tests reflect that.
@zoecarver zoecarver requested a review from a team as a code owner June 15, 2023 16:33
@zoecarver
Copy link
Contributor Author

@swift-ci please test

@zoecarver zoecarver merged commit 2cf1917 into swiftlang:release/5.9 Jun 15, 2023
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