Skip to content

Use the accessor names as written in Objective-C. #27557

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 3 commits into from
Oct 8, 2019
Merged

Use the accessor names as written in Objective-C. #27557

merged 3 commits into from
Oct 8, 2019

Conversation

varungandhi-apple
Copy link
Contributor

@varungandhi-apple varungandhi-apple commented Oct 6, 2019

Not 100% sure if my approach taken here is correct. It is unclear to me what the semantics of getParsedAccessor are supposed to be in the presence of user-written accessor names in Objective-C (as opposed to those written in Swift). Should they be passed through? Or not passed through because they are considered implicit? I've assumed that the existing behavior of getParsedAccessor is correct, so we use getAccessor instead.

Fixes rdar://problem/55519276.

Related: commit 0c5d52d (PR #26461) where getParsedAccessor was introduced.

@varungandhi-apple
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 6, 2019

Build failed
Swift Test Linux Platform
Git Sha - 3cfb05da280afbcfb7626cf6d3c3a381554f4b53

We are dropping the getter and setter names we get from Objective-C.
This leads to a runtime crash. Oops.
@varungandhi-apple
Copy link
Contributor Author

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Oct 6, 2019

Build failed
Swift Test OS X Platform
Git Sha - 3cfb05da280afbcfb7626cf6d3c3a381554f4b53

@swift-ci
Copy link
Contributor

swift-ci commented Oct 6, 2019

Build failed
Swift Test Linux Platform
Git Sha - 3cfb05da280afbcfb7626cf6d3c3a381554f4b53

@rjmccall
Copy link
Contributor

rjmccall commented Oct 7, 2019

IIRC, Slava was aiming to eliminate uses of the raw getAccessor method. I think getParsedAccessor is meant to be solely about what was written in source, so it's reasonable to say that we shouldn't be using it in this semantic method, but it's not clear to me that there's currently a better method, since we (apparently) can't assert as a precondition that this is an @objc property. Slava would have thoughts.

@slavapestov
Copy link
Contributor

slavapestov commented Oct 7, 2019

I think the right fix is to not mark imported accessors that correspond to objc methods as implicit. Only bona fide synthesized accessors should be implicit (eg, those for stored properties of structs, or a modify accessor synthesized when a property witnesses a mutable protocol requirement, etc).

And John is right, we should not be introducing new usages of getAccessor(), and existing usages should mostly be removed (except for a few places such as the AST verifier where we don't want to trigger synthesis).

@varungandhi-apple
Copy link
Contributor Author

@swift-ci please test Linux platform

It is fine if we synthesize the accessors a bit more than usual as
PrintAsObjC isn't performance-sensitive and IRGen needs the accessors
anyways.
@varungandhi-apple
Copy link
Contributor Author

@swift-ci please test

@varungandhi-apple
Copy link
Contributor Author

Note: I've added a new commit as I think @edymtt cherry-picked the first two commits elsewhere, so I didn't want to mess with history by squashing the third commit on top of the second one, just in case it causes issues.

@swift-ci
Copy link
Contributor

swift-ci commented Oct 8, 2019

Build failed
Swift Test Linux Platform
Git Sha - 3b9dbd5

@swift-ci
Copy link
Contributor

swift-ci commented Oct 8, 2019

Build failed
Swift Test OS X Platform
Git Sha - 3b9dbd5

@varungandhi-apple
Copy link
Contributor Author

Note for anyone else reading: the imported accessor is explicit in the existing code. Which is correct behavior. Hence, I didn't make any changes there.

@varungandhi-apple varungandhi-apple merged commit 04ce7bf into swiftlang:master Oct 8, 2019
@varungandhi-apple varungandhi-apple deleted the vg-fix-selector-names branch October 8, 2019 17:35
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.

5 participants