Skip to content

Commit 404d68c

Browse files
authored
Merge pull request #2551 from ahoppen/ahoppen/6.0/no-se-0418-in-5-10
[6.0] Wrap `<SyntaxNode>.parse` calls in a closure inside tests
2 parents 4638c67 + 2dff96b commit 404d68c

File tree

7 files changed

+87
-87
lines changed

7 files changed

+87
-87
lines changed

Tests/SwiftParserTest/AttributeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ final class AttributeTests: ParserTestCase {
361361

362362
assertParse(
363363
"@_implements(1️⃣\(baseType), f())",
364-
AttributeSyntax.parse,
364+
{ AttributeSyntax.parse(from: &$0) },
365365
substructure: TypeSyntax.parse(from: &parser),
366366
substructureAfterMarker: "1️⃣",
367367
line: line

Tests/SwiftParserTest/ExpressionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ final class ExpressionTests: ParserTestCase {
271271

272272
assertParse(
273273
"\\\(rootType).y",
274-
ExprSyntax.parse,
274+
{ ExprSyntax.parse(from: &$0) },
275275
substructure: KeyPathExprSyntax(
276276
root: TypeSyntax.parse(from: &parser),
277277
components: KeyPathComponentListSyntax([

Tests/SwiftParserTest/ExpressionTypeTests.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ final class ExpressionTypeTests: ParserTestCase {
7474
for (line, type) in cases {
7575
assertParse(
7676
"G<\(type)>.self",
77-
ExprSyntax.parse,
77+
{ ExprSyntax.parse(from: &$0) },
7878
substructure: IdentifierTypeSyntax(name: .identifier("X")),
7979
substructureAfterMarker: "1️⃣",
8080
line: line
@@ -84,23 +84,23 @@ final class ExpressionTypeTests: ParserTestCase {
8484
// Void
8585
assertParse(
8686
"G<1️⃣()>.self",
87-
ExprSyntax.parse,
87+
{ ExprSyntax.parse(from: &$0) },
8888
substructure: TupleTypeSyntax(elements: .init([])),
8989
substructureAfterMarker: "1️⃣"
9090
)
9191

9292
// Any
9393
assertParse(
9494
"G<1️⃣Any>.self",
95-
ExprSyntax.parse,
95+
{ ExprSyntax.parse(from: &$0) },
9696
substructure: IdentifierTypeSyntax(name: .keyword(.Any)),
9797
substructureAfterMarker: "1️⃣"
9898
)
9999

100100
// Self
101101
assertParse(
102102
"G<1️⃣Self>.self",
103-
ExprSyntax.parse,
103+
{ ExprSyntax.parse(from: &$0) },
104104
substructure: IdentifierTypeSyntax(name: .keyword(.Self)),
105105
substructureAfterMarker: "1️⃣"
106106
)

Tests/SwiftParserTest/TypeCompositionTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ final class TypeCompositionTests: ParserTestCase {
5151

5252
assertParse(
5353
"\(component) & \(component) & \(component)",
54-
TypeSyntax.parse,
54+
{ TypeSyntax.parse(from: &$0) },
5555
substructure: CompositionTypeSyntax(
5656
elements: .init([
5757
CompositionTypeElementSyntax(type: componentSyntax, ampersand: .binaryOperator("&")),

Tests/SwiftParserTest/TypeMemberTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class TypeMemberTests: ParserTestCase {
1818
func testKeyword() {
1919
assertParse(
2020
"MyType.class",
21-
TypeSyntax.parse,
21+
{ TypeSyntax.parse(from: &$0) },
2222
substructure: MemberTypeSyntax(
2323
baseType: IdentifierTypeSyntax(
2424
name: .identifier("MyType")
@@ -31,7 +31,7 @@ final class TypeMemberTests: ParserTestCase {
3131
func testMissing() {
3232
assertParse(
3333
"MyType.1️⃣",
34-
TypeSyntax.parse,
34+
{ TypeSyntax.parse(from: &$0) },
3535
substructure: MemberTypeSyntax(
3636
baseType: IdentifierTypeSyntax(
3737
name: .identifier("MyType")
@@ -69,7 +69,7 @@ final class TypeMemberTests: ParserTestCase {
6969
for (line, source) in cases {
7070
assertParse(
7171
source,
72-
TypeSyntax.parse,
72+
{ TypeSyntax.parse(from: &$0) },
7373
substructure: expected,
7474
line: line
7575
)
@@ -86,7 +86,7 @@ final class TypeMemberTests: ParserTestCase {
8686
for (line, source) in cases {
8787
assertParse(
8888
source,
89-
TypeSyntax.parse,
89+
{ TypeSyntax.parse(from: &$0) },
9090
diagnostics: [DiagnosticSpec(message: "extraneous whitespace after '.' is not permitted", fixIts: ["remove whitespace"])],
9191
fixedSource: expected,
9292
line: line
@@ -136,14 +136,14 @@ final class TypeMemberTests: ParserTestCase {
136136

137137
assertParse(
138138
"\(baseType).Z",
139-
TypeSyntax.parse,
139+
{ TypeSyntax.parse(from: &$0) },
140140
substructure: expectedSyntax,
141141
line: line
142142
)
143143

144144
assertParse(
145145
"\(baseType).Z<W>",
146-
TypeSyntax.parse,
146+
{ TypeSyntax.parse(from: &$0) },
147147
substructure: expectedSyntax.with(
148148
\.genericArgumentClause,
149149
GenericArgumentClauseSyntax(

Tests/SwiftParserTest/TypeMetatypeTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ final class TypeMetatypeTests: ParserTestCase {
5555
for metaKind in [.`Type`, .`Protocol`] as [Keyword] {
5656
assertParse(
5757
"\(baseType).\(metaKind)",
58-
TypeSyntax.parse,
58+
{ TypeSyntax.parse(from: &$0) },
5959
substructure: MetatypeTypeSyntax(
6060
baseType: baseTypeSyntax,
6161
metatypeSpecifier: .keyword(metaKind)

Tests/SwiftParserTest/translated/TypeExprTests.swift

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ final class TypeExprTests: ParserTestCase {
116116
"""
117117
)
118118

119-
assertParse("(X).Y.self", ExprSyntax.parse)
120-
assertParse("(X.Y).Z.self", ExprSyntax.parse)
121-
assertParse("((X).Y).Z.self", ExprSyntax.parse)
119+
assertParse("(X).Y.self", { ExprSyntax.parse(from: &$0) })
120+
assertParse("(X.Y).Z.self", { ExprSyntax.parse(from: &$0) })
121+
assertParse("((X).Y).Z.self", { ExprSyntax.parse(from: &$0) })
122122
}
123123

124124
func testTypeExpr9() {
@@ -154,9 +154,9 @@ final class TypeExprTests: ParserTestCase {
154154
"""
155155
)
156156

157-
assertParse("X?.self", ExprSyntax.parse)
158-
assertParse("[X].self", ExprSyntax.parse)
159-
assertParse("[X : Y].self", ExprSyntax.parse)
157+
assertParse("X?.self", { ExprSyntax.parse(from: &$0) })
158+
assertParse("[X].self", { ExprSyntax.parse(from: &$0) })
159+
assertParse("[X : Y].self", { ExprSyntax.parse(from: &$0) })
160160
}
161161

162162
func testTypeExpr11() {
@@ -182,12 +182,12 @@ final class TypeExprTests: ParserTestCase {
182182
"""
183183
)
184184

185-
assertParse("(G<X>).Y.self", ExprSyntax.parse)
186-
assertParse("X?.Y.self", ExprSyntax.parse)
187-
assertParse("(X)?.Y.self", ExprSyntax.parse)
188-
assertParse("(X?).Y.self", ExprSyntax.parse)
189-
assertParse("[X].Y.self", ExprSyntax.parse)
190-
assertParse("[X : Y].Z.self", ExprSyntax.parse)
185+
assertParse("(G<X>).Y.self", { ExprSyntax.parse(from: &$0) })
186+
assertParse("X?.Y.self", { ExprSyntax.parse(from: &$0) })
187+
assertParse("(X)?.Y.self", { ExprSyntax.parse(from: &$0) })
188+
assertParse("(X?).Y.self", { ExprSyntax.parse(from: &$0) })
189+
assertParse("[X].Y.self", { ExprSyntax.parse(from: &$0) })
190+
assertParse("[X : Y].Z.self", { ExprSyntax.parse(from: &$0) })
191191
}
192192

193193
func testTypeExpr12() {
@@ -578,107 +578,107 @@ final class TypeExprTests: ParserTestCase {
578578
}
579579

580580
func testCompositionTypeExpr() {
581-
assertParse("P & Q", ExprSyntax.parse)
582-
assertParse("P & Q.self", ExprSyntax.parse)
583-
assertParse("any P & Q", ExprSyntax.parse)
581+
assertParse("P & Q", { ExprSyntax.parse(from: &$0) })
582+
assertParse("P & Q.self", { ExprSyntax.parse(from: &$0) })
583+
assertParse("any P & Q", { ExprSyntax.parse(from: &$0) })
584584

585-
assertParse("(P & Q).self", ExprSyntax.parse)
586-
assertParse("((P) & (Q)).self", ExprSyntax.parse)
585+
assertParse("(P & Q).self", { ExprSyntax.parse(from: &$0) })
586+
assertParse("((P) & (Q)).self", { ExprSyntax.parse(from: &$0) })
587587

588-
assertParse("(A.B & C.D).self", ExprSyntax.parse)
589-
assertParse("((A).B & (C).D).self", ExprSyntax.parse)
588+
assertParse("(A.B & C.D).self", { ExprSyntax.parse(from: &$0) })
589+
assertParse("((A).B & (C).D).self", { ExprSyntax.parse(from: &$0) })
590590

591-
assertParse("(G<X> & G<Y>).self", ExprSyntax.parse)
592-
assertParse("(X? & Y?).self", ExprSyntax.parse)
593-
assertParse("([X] & [Y]).self", ExprSyntax.parse)
594-
assertParse("([A : B] & [C : D]).self", ExprSyntax.parse)
591+
assertParse("(G<X> & G<Y>).self", { ExprSyntax.parse(from: &$0) })
592+
assertParse("(X? & Y?).self", { ExprSyntax.parse(from: &$0) })
593+
assertParse("([X] & [Y]).self", { ExprSyntax.parse(from: &$0) })
594+
assertParse("([A : B] & [C : D]).self", { ExprSyntax.parse(from: &$0) })
595595

596-
assertParse("(G<A>.B & G<C>.D).self", ExprSyntax.parse)
597-
assertParse("(A?.B & C?.D).self", ExprSyntax.parse)
598-
assertParse("([A].B & [A].B).self", ExprSyntax.parse)
599-
assertParse("([A : B].C & [D : E].F).self", ExprSyntax.parse)
596+
assertParse("(G<A>.B & G<C>.D).self", { ExprSyntax.parse(from: &$0) })
597+
assertParse("(A?.B & C?.D).self", { ExprSyntax.parse(from: &$0) })
598+
assertParse("([A].B & [A].B).self", { ExprSyntax.parse(from: &$0) })
599+
assertParse("([A : B].C & [D : E].F).self", { ExprSyntax.parse(from: &$0) })
600600

601-
assertParse("(X.Type & Y.Type).self", ExprSyntax.parse)
602-
assertParse("(X.Protocol & Y.Protocol).self", ExprSyntax.parse)
601+
assertParse("(X.Type & Y.Type).self", { ExprSyntax.parse(from: &$0) })
602+
assertParse("(X.Protocol & Y.Protocol).self", { ExprSyntax.parse(from: &$0) })
603603

604-
assertParse("((A, B) & (C, D)).self", ExprSyntax.parse)
604+
assertParse("((A, B) & (C, D)).self", { ExprSyntax.parse(from: &$0) })
605605
}
606606

607607
func testTupleTypeExpr() {
608-
assertParse("(X).self", ExprSyntax.parse)
608+
assertParse("(X).self", { ExprSyntax.parse(from: &$0) })
609609

610-
assertParse("(X, Y)", ExprSyntax.parse)
610+
assertParse("(X, Y)", { ExprSyntax.parse(from: &$0) })
611611

612-
assertParse("(X, Y).self", ExprSyntax.parse)
613-
assertParse("((X), (Y)).self", ExprSyntax.parse)
612+
assertParse("(X, Y).self", { ExprSyntax.parse(from: &$0) })
613+
assertParse("((X), (Y)).self", { ExprSyntax.parse(from: &$0) })
614614

615-
assertParse("(A.B, C.D).self", ExprSyntax.parse)
616-
assertParse("((A).B, (C).D).self", ExprSyntax.parse)
615+
assertParse("(A.B, C.D).self", { ExprSyntax.parse(from: &$0) })
616+
assertParse("((A).B, (C).D).self", { ExprSyntax.parse(from: &$0) })
617617

618-
assertParse("(G<X>, G<Y>).self", ExprSyntax.parse)
619-
assertParse("(X?, Y?).self", ExprSyntax.parse)
620-
assertParse("([X], [Y]).self", ExprSyntax.parse)
621-
assertParse("([A : B], [C : D]).self", ExprSyntax.parse)
618+
assertParse("(G<X>, G<Y>).self", { ExprSyntax.parse(from: &$0) })
619+
assertParse("(X?, Y?).self", { ExprSyntax.parse(from: &$0) })
620+
assertParse("([X], [Y]).self", { ExprSyntax.parse(from: &$0) })
621+
assertParse("([A : B], [C : D]).self", { ExprSyntax.parse(from: &$0) })
622622

623-
assertParse("(G<A>.B, G<C>.D).self", ExprSyntax.parse)
624-
assertParse("(A?.B, C?.D).self", ExprSyntax.parse)
625-
assertParse("([A].B, [C].D).self", ExprSyntax.parse)
626-
assertParse("([A : B].C, [D : E].F).self", ExprSyntax.parse)
623+
assertParse("(G<A>.B, G<C>.D).self", { ExprSyntax.parse(from: &$0) })
624+
assertParse("(A?.B, C?.D).self", { ExprSyntax.parse(from: &$0) })
625+
assertParse("([A].B, [C].D).self", { ExprSyntax.parse(from: &$0) })
626+
assertParse("([A : B].C, [D : E].F).self", { ExprSyntax.parse(from: &$0) })
627627

628-
assertParse("(X.Type, Y.Type).self", ExprSyntax.parse)
629-
assertParse("(X.Protocol, Y.Protocol).self", ExprSyntax.parse)
628+
assertParse("(X.Type, Y.Type).self", { ExprSyntax.parse(from: &$0) })
629+
assertParse("(X.Protocol, Y.Protocol).self", { ExprSyntax.parse(from: &$0) })
630630

631-
assertParse("(P & Q, P & Q).self", ExprSyntax.parse)
631+
assertParse("(P & Q, P & Q).self", { ExprSyntax.parse(from: &$0) })
632632

633633
assertParse(
634634
"""
635635
(
636636
(G<X>.Y) -> (P) & X?.Y, (X.Y, [X : Y?].Type), [(G<X>).Y], [A.B.C].D
637637
).self
638638
""",
639-
ExprSyntax.parse
639+
{ ExprSyntax.parse(from: &$0) }
640640
)
641641
}
642642

643643
func testFunctionTypeExpr() {
644-
assertParse("X -> Y", ExprSyntax.parse)
645-
assertParse("(X) -> Y", ExprSyntax.parse)
646-
assertParse("(X) -> Y -> Z", ExprSyntax.parse)
647-
assertParse("P & Q -> X", ExprSyntax.parse)
648-
assertParse("A & B -> C & D -> X", ExprSyntax.parse)
649-
assertParse("(X -> Y).self", ExprSyntax.parse)
650-
assertParse("(A & B -> C & D).self", ExprSyntax.parse)
644+
assertParse("X -> Y", { ExprSyntax.parse(from: &$0) })
645+
assertParse("(X) -> Y", { ExprSyntax.parse(from: &$0) })
646+
assertParse("(X) -> Y -> Z", { ExprSyntax.parse(from: &$0) })
647+
assertParse("P & Q -> X", { ExprSyntax.parse(from: &$0) })
648+
assertParse("A & B -> C & D -> X", { ExprSyntax.parse(from: &$0) })
649+
assertParse("(X -> Y).self", { ExprSyntax.parse(from: &$0) })
650+
assertParse("(A & B -> C & D).self", { ExprSyntax.parse(from: &$0) })
651651

652-
assertParse("((X) -> Y).self", ExprSyntax.parse)
653-
assertParse("(((X)) -> (Y)).self", ExprSyntax.parse)
652+
assertParse("((X) -> Y).self", { ExprSyntax.parse(from: &$0) })
653+
assertParse("(((X)) -> (Y)).self", { ExprSyntax.parse(from: &$0) })
654654

655-
assertParse("((A.B) -> C.D).self", ExprSyntax.parse)
656-
assertParse("(((A).B) -> (C).D).self", ExprSyntax.parse)
655+
assertParse("((A.B) -> C.D).self", { ExprSyntax.parse(from: &$0) })
656+
assertParse("(((A).B) -> (C).D).self", { ExprSyntax.parse(from: &$0) })
657657

658-
assertParse("((G<X>) -> G<Y>).self", ExprSyntax.parse)
659-
assertParse("((X?) -> Y?).self", ExprSyntax.parse)
660-
assertParse("(([X]) -> [Y]).self", ExprSyntax.parse)
661-
assertParse("(([A : B]) -> [C : D]).self", ExprSyntax.parse)
658+
assertParse("((G<X>) -> G<Y>).self", { ExprSyntax.parse(from: &$0) })
659+
assertParse("((X?) -> Y?).self", { ExprSyntax.parse(from: &$0) })
660+
assertParse("(([X]) -> [Y]).self", { ExprSyntax.parse(from: &$0) })
661+
assertParse("(([A : B]) -> [C : D]).self", { ExprSyntax.parse(from: &$0) })
662662

663-
assertParse("((Gen<Foo>.Bar) -> Gen<Foo>.Bar).self", ExprSyntax.parse)
664-
assertParse("((Foo?.Bar) -> Foo?.Bar).self", ExprSyntax.parse)
665-
assertParse("(([Foo].Element) -> [Foo].Element).self", ExprSyntax.parse)
666-
assertParse("(([Int : Foo].Element) -> [Int : Foo].Element).self", ExprSyntax.parse)
663+
assertParse("((Gen<Foo>.Bar) -> Gen<Foo>.Bar).self", { ExprSyntax.parse(from: &$0) })
664+
assertParse("((Foo?.Bar) -> Foo?.Bar).self", { ExprSyntax.parse(from: &$0) })
665+
assertParse("(([Foo].Element) -> [Foo].Element).self", { ExprSyntax.parse(from: &$0) })
666+
assertParse("(([Int : Foo].Element) -> [Int : Foo].Element).self", { ExprSyntax.parse(from: &$0) })
667667

668-
assertParse("((X.Type) -> Y.Type).self", ExprSyntax.parse)
669-
assertParse("((X.Protocol) -> Y.Protocol).self", ExprSyntax.parse)
668+
assertParse("((X.Type) -> Y.Type).self", { ExprSyntax.parse(from: &$0) })
669+
assertParse("((X.Protocol) -> Y.Protocol).self", { ExprSyntax.parse(from: &$0) })
670670

671-
assertParse("(() -> X & Y).self", ExprSyntax.parse)
672-
assertParse("((A & B) -> C & D).self", ExprSyntax.parse)
673-
assertParse("((A & B) -> (C & D) -> E & Any).self", ExprSyntax.parse)
671+
assertParse("(() -> X & Y).self", { ExprSyntax.parse(from: &$0) })
672+
assertParse("((A & B) -> C & D).self", { ExprSyntax.parse(from: &$0) })
673+
assertParse("((A & B) -> (C & D) -> E & Any).self", { ExprSyntax.parse(from: &$0) })
674674

675675
assertParse(
676676
"""
677677
(
678678
((P) & X?.Y, G<X>.Y, (X, [A : B?].Type)) -> ([(X).Y]) -> [X].Y
679679
).self
680680
""",
681-
ExprSyntax.parse
681+
{ ExprSyntax.parse(from: &$0) }
682682
)
683683
}
684684

0 commit comments

Comments
 (0)