File tree Expand file tree Collapse file tree 9 files changed +57
-2
lines changed
test/refactoring/TrailingClosure Expand file tree Collapse file tree 9 files changed +57
-2
lines changed Original file line number Diff line number Diff line change @@ -2775,7 +2775,7 @@ bool RefactoringActionTrailingClosure::performChange() {
2775
2775
return true ;
2776
2776
Expr *Args = CE->getArg ();
2777
2777
if (auto *TSE = dyn_cast<TupleShuffleExpr>(Args))
2778
- Args = TSE;
2778
+ Args = TSE-> getSubExpr () ;
2779
2779
2780
2780
Expr *ClosureArg = nullptr ;
2781
2781
Expr *PrevArg = nullptr ;
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ func testTrailingClosure() -> String {
14
14
.map({ $0 + 1 })
15
15
}
16
16
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar(closure: { print("foo") })
20
+ }
17
21
18
22
19
23
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ func testTrailingClosure() -> String {
14
14
.map({ $0 + 1 })
15
15
}
16
16
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar(closure: { print("foo") })
20
+ }
17
21
18
22
19
23
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ func testTrailingClosure() -> String {
14
14
.map { $0 + 1 }
15
15
}
16
16
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar(closure: { print("foo") })
20
+ }
17
21
18
22
19
23
Original file line number Diff line number Diff line change
1
+ struct Foo {
2
+ static func foo(a: () -> Int) {}
3
+ func qux(x: Int, y: () -> Int ) {}
4
+ }
5
+
6
+ func testTrailingClosure() -> String {
7
+ Foo.foo(a: { 1 })
8
+ Foo.bar(a: { print(3); return 1 })
9
+ Foo().qux(x: 1, y: { 1 })
10
+ let _ = Foo().quux(x: 1, y: { 1 })
11
+
12
+ [1,2,3]
13
+ .filter({ $0 % 2 == 0 })
14
+ .map({ $0 + 1 })
15
+ }
16
+
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar { print("foo") }
20
+ }
21
+
22
+
23
+
24
+
25
+
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ func testTrailingClosure() -> String {
14
14
.map({ $0 + 1 })
15
15
}
16
16
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar(closure: { print("foo") })
20
+ }
17
21
18
22
19
23
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ func testTrailingClosure() -> String {
14
14
.map({ $0 + 1 })
15
15
}
16
16
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar(closure: { print("foo") })
20
+ }
17
21
18
22
19
23
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ func testTrailingClosure() -> String {
14
14
.map({ $0 + 1 })
15
15
}
16
16
17
+ func foobar(first: String? = nil, closure: () -> Void) { fatalError() }
18
+ func blah() {
19
+ _ = foobar(closure: { print("foo") })
20
+ }
17
21
18
22
19
23
Original file line number Diff line number Diff line change @@ -13,6 +13,11 @@ func testTrailingClosure() -> String {
13
13
. filter ( { $0 % 2 == 0 } )
14
14
. map ( { $0 + 1 } )
15
15
}
16
+
17
+ func foobar( first: String ? = nil , closure: ( ) -> Void ) { fatalError ( ) }
18
+ func blah( ) {
19
+ _ = foobar ( closure: { print ( " foo " ) } )
20
+ }
16
21
// RUN: %empty-directory(%t.result)
17
22
18
23
// RUN: %refactor -trailingclosure -source-filename %s -pos=7:3 > %t.result/L7.swift
@@ -31,4 +36,5 @@ func testTrailingClosure() -> String {
31
36
// RUN: diff -u %S/Outputs/basic/L13.swift.expected %t.result/L13.swift
32
37
// RUN: %refactor -trailingclosure -source-filename %s -pos=14:5 > %t.result/L14.swift
33
38
// RUN: diff -u %S/Outputs/basic/L14.swift.expected %t.result/L14.swift
34
-
39
+ // RUN: %refactor -trailingclosure -source-filename %s -pos=19:7 > %t.result/L19.swift
40
+ // RUN: diff -u %S/Outputs/basic/L19.swift.expected %t.result/L19.swift
You can’t perform that action at this time.
0 commit comments