@@ -40,10 +40,7 @@ extension VariableDeclSyntax {
40
40
}
41
41
42
42
func accessorsMatching( _ predicate: ( TokenKind ) -> Bool ) -> [ AccessorDeclSyntax ] {
43
- let patternBindings = bindings. compactMap { binding in
44
- binding. as ( PatternBindingSyntax . self)
45
- }
46
- let accessors : [ AccessorDeclListSyntax . Element ] = patternBindings. compactMap { patternBinding in
43
+ let accessors : [ AccessorDeclListSyntax . Element ] = bindings. compactMap { patternBinding in
47
44
switch patternBinding. accessorBlock? . accessors {
48
45
case . accessors( let accessors) :
49
46
return accessors
@@ -52,11 +49,8 @@ extension VariableDeclSyntax {
52
49
}
53
50
} . flatMap { $0 }
54
51
return accessors. compactMap { accessor in
55
- guard let decl = accessor. as ( AccessorDeclSyntax . self) else {
56
- return nil
57
- }
58
- if predicate ( decl. accessorSpecifier. tokenKind) {
59
- return decl
52
+ if predicate ( accessor. accessorSpecifier. tokenKind) {
53
+ return accessor
60
54
} else {
61
55
return nil
62
56
}
@@ -211,7 +205,7 @@ extension DeclGroupSyntax {
211
205
var memberFunctionStandins : [ FunctionDeclSyntax . SignatureStandin ] {
212
206
var standins = [ FunctionDeclSyntax . SignatureStandin] ( )
213
207
for member in memberBlock. members {
214
- if let function = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( FunctionDeclSyntax . self) {
208
+ if let function = member. decl. as ( FunctionDeclSyntax . self) {
215
209
standins. append ( function. signatureStandin)
216
210
}
217
211
}
@@ -220,7 +214,7 @@ extension DeclGroupSyntax {
220
214
221
215
func hasMemberFunction( equvalentTo other: FunctionDeclSyntax ) -> Bool {
222
216
for member in memberBlock. members {
223
- if let function = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( FunctionDeclSyntax . self) {
217
+ if let function = member. decl. as ( FunctionDeclSyntax . self) {
224
218
if function. isEquivalent ( to: other) {
225
219
return true
226
220
}
@@ -231,7 +225,7 @@ extension DeclGroupSyntax {
231
225
232
226
func hasMemberProperty( equivalentTo other: VariableDeclSyntax ) -> Bool {
233
227
for member in memberBlock. members {
234
- if let variable = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( VariableDeclSyntax . self) {
228
+ if let variable = member. decl. as ( VariableDeclSyntax . self) {
235
229
if variable. isEquivalent ( to: other) {
236
230
return true
237
231
}
@@ -242,7 +236,7 @@ extension DeclGroupSyntax {
242
236
243
237
var definedVariables : [ VariableDeclSyntax ] {
244
238
memberBlock. members. compactMap { member in
245
- if let variableDecl = member. as ( MemberBlockItemSyntax . self ) ? . decl. as ( VariableDeclSyntax . self) {
239
+ if let variableDecl = member. decl. as ( VariableDeclSyntax . self) {
246
240
return variableDecl
247
241
}
248
242
return nil
0 commit comments