Skip to content

SILGen: Handle key paths with @objc optional property and subscript components #42137

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 6 commits into from
Apr 2, 2022

Conversation

AnthonyLatsis
Copy link
Collaborator

@AnthonyLatsis AnthonyLatsis commented Apr 1, 2022

Resolves #58337

@AnthonyLatsis
Copy link
Collaborator Author

@swift-ci please smoke test macOS

@AnthonyLatsis
Copy link
Collaborator Author

Note that this will still crash during SIL generation if the optional requirement has a setter. I wonder why optional requirements are even allowed to have a setter if we lack the plumbing for that case.

@jckarter
Copy link
Contributor

jckarter commented Apr 1, 2022

Thanks! Yeah, setters on optional properties (and on properties found through dynamic member lookup on AnyObject) were one thing we put off thinking we could come up with a clever way to model, but never got around to. Modeling the key path component as get-only should be sufficient in the meantime.

@jckarter
Copy link
Contributor

jckarter commented Apr 1, 2022

@swift-ci Please test

@AnthonyLatsis
Copy link
Collaborator Author

Modeling the key path component as get-only should be sufficient in the meantime.

Will do in a follow-up!

@AnthonyLatsis AnthonyLatsis merged commit 62a2c9e into swiftlang:main Apr 2, 2022
@AnthonyLatsis AnthonyLatsis deleted the objc-optional-keypath branch April 2, 2022 10:53
@jckarter
Copy link
Contributor

It looks like the type checker after this change still treats a key path referencing an @objc optional property as a WritableKeyPath, which after this fix, causes us to still crash if people try to do something like foo[keyPath: \.optionalProperty] = bar. Would you be able to fix that aspect as well?

@AnthonyLatsis
Copy link
Collaborator Author

AnthonyLatsis commented Apr 14, 2022

Sorry, got carried away, I'm on it now!

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.

[SR-16076] Compiler crashes in release mode when using compactMap with a key path to an @objc optional property
3 participants