Skip to content

[Stdlib] Fix swift_setAtWritableKeyPath to check for ReferenceWritableKeyPaths. #34729

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

mikeash
Copy link
Contributor

@mikeash mikeash commented Nov 13, 2020

Call through to swift_setAtReferenceWritableKeyPath in that case. This fixes an assertion failure (or worse) when upcasting a ReferenceWritableKeyPath and then using subscript(keyPath:) to write a value with it.

rdar://problem/70609888

…eKeyPaths.

Call through to swift_setAtReferenceWritableKeyPath in that case. This fixes an assertion failure (or worse) when upcasting a ReferenceWritableKeyPath and then using subscript(keyPath:) to write a value with it.

rdar://problem/70609888
@mikeash mikeash requested a review from jckarter November 13, 2020 18:02
@mikeash
Copy link
Contributor Author

mikeash commented Nov 13, 2020

@swift-ci please test

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

Looks good, thanks Mike!

@mikeash
Copy link
Contributor Author

mikeash commented Nov 13, 2020

@jckarter And thank you for the help in figuring it out!

@jckarter
Copy link
Contributor

Another approach might be to see if the Writable and ReferenceWritable projection implementations can be unified, since the only real difference is the handling of the reference prefix in the latter case. But this is good to fix the immediate bug.

@mikeash
Copy link
Contributor Author

mikeash commented Nov 13, 2020

Yeah, it does look like the reference-y bits could pretty easily go into WritableKeyPath, and then ReferenceWritableKeyPath would just be a stub subclass. I'll save that adventure for another day though.

@mikeash
Copy link
Contributor Author

mikeash commented Nov 13, 2020

@swift-ci please test windows platform

@mikeash mikeash merged commit 2442ba2 into swiftlang:main Nov 13, 2020
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.

2 participants