diff --git a/Package.resolved b/Package.resolved index c34d64dd49..6cc700d5b5 100644 --- a/Package.resolved +++ b/Package.resolved @@ -32,7 +32,7 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-syntax.git", "state" : { - "revision" : "76d01195182593ff34f5ada1ab0910fae190fc9c" + "revision" : "6fcc5a4b897351766da9dca9d14e26897ca17dc7" } }, { diff --git a/Package.swift b/Package.swift index 6b658bc159..8b996c02d6 100644 --- a/Package.swift +++ b/Package.swift @@ -30,7 +30,7 @@ let package = Package( ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser.git", .upToNextMinor(from: "1.2.0")), - .package(url: "https://github.com/apple/swift-syntax.git", revision: "76d01195182593ff34f5ada1ab0910fae190fc9c"), + .package(url: "https://github.com/apple/swift-syntax.git", revision: "6fcc5a4b897351766da9dca9d14e26897ca17dc7"), .package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.33.1")), .package(url: "https://github.com/jpsim/Yams.git", from: "5.0.1"), .package(url: "https://github.com/scottrhoyt/SwiftyTextTable.git", from: "0.9.0"), diff --git a/Source/SwiftLintFramework/Rules/Style/PreferSelfInStaticReferencesRule.swift b/Source/SwiftLintFramework/Rules/Style/PreferSelfInStaticReferencesRule.swift index e8f05c6ea3..af7ef9acf7 100644 --- a/Source/SwiftLintFramework/Rules/Style/PreferSelfInStaticReferencesRule.swift +++ b/Source/SwiftLintFramework/Rules/Style/PreferSelfInStaticReferencesRule.swift @@ -83,6 +83,17 @@ struct PreferSelfInStaticReferencesRule: SwiftSyntaxRule, CorrectableRule, Confi """, excludeFromDocumentation: true) ], triggeringExamples: [ + Example(""" + final class CheckCellView: NSTableCellView { + @IBOutlet var checkButton: NSButton! + + override func awakeFromNib() { + checkButton.action = #selector(↓CheckCellView.check(_:)) + } + + @objc func check(_ button: AnyObject?) {} + } + """), Example(""" class C { struct S { @@ -146,6 +157,28 @@ struct PreferSelfInStaticReferencesRule: SwiftSyntaxRule, CorrectableRule, Confi """, excludeFromDocumentation: true) ], corrections: [ + Example(""" + final class CheckCellView: NSTableCellView { + @IBOutlet var checkButton: NSButton! + + override func awakeFromNib() { + checkButton.action = #selector(↓CheckCellView.check(_:)) + } + + @objc func check(_ button: AnyObject?) {} + } + """): + Example(""" + final class CheckCellView: NSTableCellView { + @IBOutlet var checkButton: NSButton! + + override func awakeFromNib() { + checkButton.action = #selector(Self.check(_:)) + } + + @objc func check(_ button: AnyObject?) {} + } + """), Example(""" struct S { static let i = 1 @@ -296,8 +329,8 @@ private class Visitor: ViolationsSyntaxVisitor { _ = variableDeclScopes.popLast() } - override func visit(_ node: ObjcKeyPathExprSyntax) -> SyntaxVisitorContinueKind { - if case .likeStruct = parentDeclScopes.last { + override func visit(_ node: MacroExpansionExprSyntax) -> SyntaxVisitorContinueKind { + if case .likeClass = parentDeclScopes.last, case .identifier("selector") = node.macro.tokenKind { return .visitChildren } return .skipChildren diff --git a/bazel/repos.bzl b/bazel/repos.bzl index 3ef8e826e9..7203aa268a 100644 --- a/bazel/repos.bzl +++ b/bazel/repos.bzl @@ -19,10 +19,10 @@ def swiftlint_repos(): http_archive( name = "com_github_apple_swift_syntax", - sha256 = "4f244c3acac972817579517d8799c702e5c36d223ab8ab596d9b63010e35e1c6", # SwiftSyntax sha256 + sha256 = "17bdf4c9c87bac4f7160be1ca2e4e0101f97f7b75181e18df62b3e425ea753d8", # SwiftSyntax sha256 build_file = "@SwiftLint//bazel:SwiftSyntax.BUILD", - strip_prefix = "swift-syntax-76d01195182593ff34f5ada1ab0910fae190fc9c", - url = "https://github.com/apple/swift-syntax/archive/76d01195182593ff34f5ada1ab0910fae190fc9c.tar.gz", + strip_prefix = "swift-syntax-6fcc5a4b897351766da9dca9d14e26897ca17dc7", + url = "https://github.com/apple/swift-syntax/archive/6fcc5a4b897351766da9dca9d14e26897ca17dc7.tar.gz", ) http_archive(