-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
unused_capture_list false positive with explicit capturing of strong self in Swift 5.3 #3267
Comments
Hmm, looks like the Swift compiler actually warns on unused captures, so I wonder if we should just remove the rule instead:
|
…3352) ## Summary This pr fixes: #3267 . Since Swift 5.3 is released. It support implicit self in @escaping closures([SE-0269](https://github.com/apple/swift-evolution/blob/master/proposals/0269-implicit-self-explicit-capture.md)) I think we should exclude self keyword from capture list rule. ## Test Plan I have already add some test in example. Thanks you so much for your code review!
Looks like this isn't handling all cases, if class A {
func foo() {}
func bar() {
_ = { [unowned self] in // Unused reference self in a capture list should be removed. (SwiftLint: unused_capture_list)
foo()
}
}
} |
I'm having the same issue. I think that this issue should be reopened. |
For anyone looking around like me, the unowned issue was opened here. It was fixed and merged but not yet released. |
New Issue Checklist
Describe the bug
A new feature in Swift 5.3 allows to explicitly capture strong self and then drop the self. prefix in the closure (see SE-0269). However, SwiftLint's unused_capture_list then treats the capture as unused, because self is not explicitly written out. It is still used implicitly though, so it should not produce an error.
See below for an example.
Complete output when running SwiftLint, including the stack trace and command used
Environment
SwiftLint version (run
swiftlint version
to be sure)?Installation method used (Homebrew, CocoaPods, building from source, etc)?
Paste your configuration file:
Are you using nested configurations?
If so, paste their relative paths and respective contents.
Which Xcode version are you using (check
xcodebuild -version
)?The text was updated successfully, but these errors were encountered: