77import Foundation
88import ConvertBoolObjC
99
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 ) { }
1313
1414// All 7 of the below should generate the same refactoring.
1515
@@ -185,7 +185,7 @@ boolWithErr { success, err in
185185 }
186186 }
187187 if !success {
188- for x : Int in [ ] {
188+ for _ : Int in [ ] {
189189 fatalError ( " oh no \( err!) " )
190190 }
191191 }
@@ -212,7 +212,7 @@ boolWithErr { success, err in
212212// BOOL-DONT-HANDLE2-NEXT: }
213213// BOOL-DONT-HANDLE2-NEXT: }
214214// BOOL-DONT-HANDLE2-NEXT: if !success {
215- // BOOL-DONT-HANDLE2-NEXT: for x : Int in [] {
215+ // BOOL-DONT-HANDLE2-NEXT: for _ : Int in [] {
216216// BOOL-DONT-HANDLE2-NEXT: fatalError("oh no \(<#err#>!)")
217217// BOOL-DONT-HANDLE2-NEXT: }
218218// BOOL-DONT-HANDLE2-NEXT: }
@@ -221,7 +221,7 @@ boolWithErr { success, err in
221221// 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
222222boolWithErr { success, err in
223223 if !success {
224- fatalError ( " oh no maybe \( err) " )
224+ fatalError ( " oh no maybe \( String ( describing : err) ) " )
225225 }
226226 print ( " not err " )
227227}
@@ -230,7 +230,7 @@ boolWithErr { success, err in
230230
231231// BOOL-DONT-HANDLE3: let success = try await boolWithErr()
232232// 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#>) )")
234234// BOOL-DONT-HANDLE3-NEXT: }
235235// BOOL-DONT-HANDLE3-NEXT: print("not err")
236236
@@ -342,7 +342,7 @@ optionalBoolWithErr { str, optBool, b, err in
342342 print ( " d \( err!) " )
343343 }
344344 if optBool == false {
345- print ( " e \( err) " )
345+ print ( " e \( String ( describing : err) ) " )
346346 }
347347 if optBool != true {
348348 print ( " f \( err!) " )
@@ -360,7 +360,7 @@ optionalBoolWithErr { str, optBool, b, err in
360360// OPT-BOOL-WITH-ERR-NEXT: let (str, optBool, b) = try await optionalBoolWithErr()
361361// OPT-BOOL-WITH-ERR-NEXT: print("a \(<#err#>!)")
362362// 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#>) )")
364364// OPT-BOOL-WITH-ERR-NEXT: }
365365// OPT-BOOL-WITH-ERR-NEXT: if <#optBool#> != true {
366366// OPT-BOOL-WITH-ERR-NEXT: print("f \(<#err#>!)")
@@ -426,7 +426,7 @@ ClassWithHandlerMethods.secondBoolFlagFailure("") { str, unrelated, failure, err
426426 if failure && err != nil {
427427 print ( " neat " )
428428 }
429- if failure, let err = err {
429+ if failure, let _ = err {
430430 print ( " neato " )
431431 }
432432}
0 commit comments