File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed
Source/SwiftLintBuiltInRules/Rules/Lint Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -190,17 +190,25 @@ private extension PatternBindingSyntax {
190
190
}
191
191
192
192
var functionTypeSyntax : FunctionTypeSyntax ? {
193
- guard let typeAnnotation else { return nil }
194
-
195
- var children = Set ( typeAnnotation . children ( viewMode : . sourceAccurate ) )
193
+ typeAnnotation? . type . baseFunctionTypeSyntax
194
+ }
195
+ }
196
196
197
- while let child = children. popFirst ( ) {
198
- if let functionType = child. as ( FunctionTypeSyntax . self) {
199
- return functionType
200
- }
201
- children. formUnion ( child. children ( viewMode: . sourceAccurate) )
197
+ private extension TypeSyntax {
198
+ var baseFunctionTypeSyntax : FunctionTypeSyntax ? {
199
+ switch Syntax ( self ) . as ( SyntaxEnum . self) {
200
+ case . functionType( let function) :
201
+ function
202
+ case . optionalType( let optional) :
203
+ optional. wrappedType. baseFunctionTypeSyntax
204
+ case . attributedType( let attributed) :
205
+ attributed. baseType. baseFunctionTypeSyntax
206
+ case . tupleType( let tuple) :
207
+ tuple. elements
208
+ . compactMap { $0. type. baseFunctionTypeSyntax }
209
+ . first
210
+ default :
211
+ nil
202
212
}
203
-
204
- return nil
205
213
}
206
214
}
Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ internal struct UnneededThrowsRuleExamples {
140
140
catch is SomeError { throw AnotherError }
141
141
catch is AnotherError {}
142
142
}
143
- """ )
143
+ """ ) ,
144
+ Example ( " let s: S<() throws -> Void> = S() " ) ,
144
145
]
145
146
146
147
static let triggeringExamples = [
You can’t perform that action at this time.
0 commit comments