Skip to content
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

[SR-12714] Explicit self. #329

Closed
weissi opened this issue May 1, 2020 · 4 comments
Closed

[SR-12714] Explicit self. #329

weissi opened this issue May 1, 2020 · 4 comments

Comments

@weissi
Copy link
Member

weissi commented May 1, 2020

Previous ID SR-12714
Radar None
Original Reporter @weissi
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels New Feature
Assignee None
Priority Medium

md5: 0eee30a579bfbe4ae0442eb637819834

Issue Description:

AFAIK, swift-format doesn't support adding explicit self. everywhere. It would be great if it could do that.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 9, 2022
@pronebird
Copy link

It does not support trimming implicit self either, so would be good to have both options.

@allevato
Copy link
Collaborator

Adding or removing explicit self would likely require semantic information about the symbols, not just the syntax, to distinguish identifiers and know whether they're members of self and that the code could be changed without changing its behavior.

It might be possible to approximate it by tracking symbols in their lexical scopes and use that to determine which symbol is being referred to, we wouldn't have access to the compiler Decls that would let us be 100% confident that self is the same as the container for some property x if it's also in the presence of other shadowing names.

@keith
Copy link
Collaborator

keith commented Jul 18, 2022

FYI SwiftLint has a semantic version of this https://github.com/realm/SwiftLint/#configuration and SwiftFormat has a best effort version where it inserts and removes only ones it's confident about AFAIUI

@allevato
Copy link
Collaborator

Closing this as not planned, since we would need semantic information to do this correctly, and I prefer not to implement a syntax-only version that is incomplete.

@allevato allevato closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants