7
7
import Foundation
8
8
import ConvertBoolObjC
9
9
10
- func boolWithErr( completion: ( Bool , Error ? ) -> Void ) { }
11
- func multipleBoolWithErr( completion: ( String ? , Bool , Bool , Error ? ) -> Void ) { }
12
- func optionalBoolWithErr( completion: ( String ? , Bool ? , Bool , Error ? ) -> Void ) { }
10
+ func boolWithErr( completion: @escaping ( Bool , Error ? ) -> Void ) { }
11
+ func multipleBoolWithErr( completion: @escaping ( String ? , Bool , Bool , Error ? ) -> Void ) { }
12
+ func optionalBoolWithErr( completion: @escaping ( String ? , Bool ? , Bool , Error ? ) -> Void ) { }
13
13
14
14
// All 7 of the below should generate the same refactoring.
15
15
@@ -185,7 +185,7 @@ boolWithErr { success, err in
185
185
}
186
186
}
187
187
if !success {
188
- for x : Int in [ ] {
188
+ for _ : Int in [ ] {
189
189
fatalError ( " oh no \( err!) " )
190
190
}
191
191
}
@@ -212,7 +212,7 @@ boolWithErr { success, err in
212
212
// BOOL-DONT-HANDLE2-NEXT: }
213
213
// BOOL-DONT-HANDLE2-NEXT: }
214
214
// BOOL-DONT-HANDLE2-NEXT: if !success {
215
- // BOOL-DONT-HANDLE2-NEXT: for x : Int in [] {
215
+ // BOOL-DONT-HANDLE2-NEXT: for _ : Int in [] {
216
216
// BOOL-DONT-HANDLE2-NEXT: fatalError("oh no \(<#err#>!)")
217
217
// BOOL-DONT-HANDLE2-NEXT: }
218
218
// BOOL-DONT-HANDLE2-NEXT: }
@@ -221,7 +221,7 @@ boolWithErr { success, err in
221
221
// RUN: %refactor -convert-call-to-async-alternative -dump-text -source-filename %s -pos=%(line+1):1 -I %S/Inputs -I %t %clang-importer-sdk-nosource | %FileCheck -check-prefix=BOOL-DONT-HANDLE3 %s
222
222
boolWithErr { success, err in
223
223
if !success {
224
- fatalError ( " oh no maybe \( err) " )
224
+ fatalError ( " oh no maybe \( String ( describing : err) ) " )
225
225
}
226
226
print ( " not err " )
227
227
}
@@ -230,7 +230,7 @@ boolWithErr { success, err in
230
230
231
231
// BOOL-DONT-HANDLE3: let success = try await boolWithErr()
232
232
// BOOL-DONT-HANDLE3-NEXT: if !success {
233
- // BOOL-DONT-HANDLE3-NEXT: fatalError("oh no maybe \(<#err#>)")
233
+ // BOOL-DONT-HANDLE3-NEXT: fatalError("oh no maybe \(String(describing: <#err#>) )")
234
234
// BOOL-DONT-HANDLE3-NEXT: }
235
235
// BOOL-DONT-HANDLE3-NEXT: print("not err")
236
236
@@ -342,7 +342,7 @@ optionalBoolWithErr { str, optBool, b, err in
342
342
print ( " d \( err!) " )
343
343
}
344
344
if optBool == false {
345
- print ( " e \( err) " )
345
+ print ( " e \( String ( describing : err) ) " )
346
346
}
347
347
if optBool != true {
348
348
print ( " f \( err!) " )
@@ -360,7 +360,7 @@ optionalBoolWithErr { str, optBool, b, err in
360
360
// OPT-BOOL-WITH-ERR-NEXT: let (str, optBool, b) = try await optionalBoolWithErr()
361
361
// OPT-BOOL-WITH-ERR-NEXT: print("a \(<#err#>!)")
362
362
// OPT-BOOL-WITH-ERR-NEXT: if <#optBool#> == false {
363
- // OPT-BOOL-WITH-ERR-NEXT: print("e \(<#err#>)")
363
+ // OPT-BOOL-WITH-ERR-NEXT: print("e \(String(describing: <#err#>) )")
364
364
// OPT-BOOL-WITH-ERR-NEXT: }
365
365
// OPT-BOOL-WITH-ERR-NEXT: if <#optBool#> != true {
366
366
// OPT-BOOL-WITH-ERR-NEXT: print("f \(<#err#>!)")
@@ -426,7 +426,7 @@ ClassWithHandlerMethods.secondBoolFlagFailure("") { str, unrelated, failure, err
426
426
if failure && err != nil {
427
427
print ( " neat " )
428
428
}
429
- if failure, let err = err {
429
+ if failure, let _ = err {
430
430
print ( " neato " )
431
431
}
432
432
}
0 commit comments