Skip to content

[cxx-interop] Update tests for mutable struct fields #64877

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
Apr 4, 2023

Conversation

egorzhdan
Copy link
Contributor

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.

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.
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Apr 3, 2023
@egorzhdan egorzhdan requested review from zoecarver and hyp as code owners April 3, 2023 20:50
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan merged commit 283d664 into main Apr 4, 2023
@egorzhdan egorzhdan deleted the egorzhdan/test-mutable-members branch April 4, 2023 10:24
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.

1 participant