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-8453] Warn when redundant access modifier is added in an extension #50974

Closed
belkadan opened this issue Aug 2, 2018 · 3 comments
Closed
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement

Comments

@belkadan
Copy link
Contributor

belkadan commented Aug 2, 2018

Previous ID SR-8453
Radar rdar://problem/28190071
Original Reporter @belkadan
Type Improvement
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Improvement, StarterBug
Assignee dingobye (JIRA)
Priority Medium

md5: f95ec8d34147d6bb418a38ceed89d1e1

Issue Description:

class SomeClass {
}

fileprivate extension SomeClass {
    fileprivate var someProperty: Int {
        return 1
    }
}

In this code, the fileprivate on the property is redundant with the one on the extension. Since access modifiers on extensions are an opt-in feature, anyone using it probably didn't intend to write the access in both places. We can warn about this.

Note that this does not apply to private, since private extension is currently equivalent to fileprivate extension, but private on the members means "within this file, visible inside this type and all of its extensions".

@belkadan
Copy link
Contributor Author

belkadan commented Aug 2, 2018

I think this could be implemented as a syntactic check in TypeCheckAttr.cpp, so tagging as a StarterBug.

@swift-ci
Copy link
Collaborator

Comment by Ding Ye (JIRA)

I can take this, since I made a relevant patch for SR-8306.

@belkadan
Copy link
Contributor Author

This happened!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself good first issue Good for newcomers improvement
Projects
None yet
Development

No branches or pull requests

2 participants