@@ -52,50 +52,92 @@ public func withErrorReporting<R>(
5252  } 
5353} 
5454
55- /// Evaluates a throwing closure and automatically catches and reports any error thrown.
56- ///
57- /// - Parameters:
58- ///   - message: A message describing the expectation.
59- ///   - reporters: Issue reporters to notify during the operation.
60- ///   - fileID: The source `#fileID` associated with the error reporting.
61- ///   - filePath: The source `#filePath` associated with the error reporting.
62- ///   - line: The source `#line` associated with the error reporting.
63- ///   - column: The source `#column` associated with the error reporting.
64- ///   - body: An asynchronous operation.
65- /// - Returns: The optional result of the operation, or `nil` if an error was thrown.
66- @_transparent  
67- public  func  withErrorReporting< R> ( 
68-   _ message:  @autoclosure  ( )  ->  String ?   =  nil , 
69-   to reporters:  [ any  IssueReporter ] ?   =  nil , 
70-   fileID:  StaticString  =  #fileID, 
71-   filePath:  StaticString  =  #filePath, 
72-   line:  UInt  =  #line, 
73-   column:  UInt  =  #column, 
74-   isolation:  isolated ( any  Actor ) ?   =  #isolation, 
75-   catching body:  ( )  async  throws  ->  sending  R
76- )  async  ->  R ?   { 
77-   if  let  reporters { 
78-     return  await  withIssueReporters ( reporters)  { 
55+ #if compiler(>=6) 
56+   /// Evaluates a throwing closure and automatically catches and reports any error thrown.
57+   ///
58+   /// - Parameters:
59+   ///   - message: A message describing the expectation.
60+   ///   - reporters: Issue reporters to notify during the operation.
61+   ///   - fileID: The source `#fileID` associated with the error reporting.
62+   ///   - filePath: The source `#filePath` associated with the error reporting.
63+   ///   - line: The source `#line` associated with the error reporting.
64+   ///   - column: The source `#column` associated with the error reporting.
65+   ///   - isolation: The isolation associated with the error reporting.
66+   ///   - body: An asynchronous operation.
67+   /// - Returns: The optional result of the operation, or `nil` if an error was thrown.
68+   @_transparent  
69+   public  func  withErrorReporting< R> ( 
70+     _ message:  @autoclosure  ( )  ->  String ?   =  nil , 
71+     to reporters:  [ any  IssueReporter ] ?   =  nil , 
72+     fileID:  StaticString  =  #fileID, 
73+     filePath:  StaticString  =  #filePath, 
74+     line:  UInt  =  #line, 
75+     column:  UInt  =  #column, 
76+     isolation:  isolated ( any  Actor ) ?   =  #isolation, 
77+     catching body:  ( )  async  throws  ->  sending  R
78+   )  async  ->  R ?   { 
79+     if  let  reporters { 
80+       return  await  withIssueReporters ( reporters)  { 
81+         do  { 
82+           return  try   await  body ( ) 
83+         }  catch  { 
84+           reportIssue ( 
85+             error, 
86+             message ( ) , 
87+             fileID:  fileID, 
88+             filePath:  filePath, 
89+             line:  line, 
90+             column:  column
91+           ) 
92+           return  nil 
93+         } 
94+       } 
95+     }  else  { 
7996      do  { 
8097        return  try   await  body ( ) 
8198      }  catch  { 
8299        reportIssue ( 
83-           error, 
84-           message ( ) , 
85-           fileID:  fileID, 
86-           filePath:  filePath, 
87-           line:  line, 
88-           column:  column
89-         ) 
100+           error,  message ( ) ,  fileID:  fileID,  filePath:  filePath,  line:  line,  column:  column) 
90101        return  nil 
91102      } 
92103    } 
93-   }  else  { 
94-     do  { 
95-       return  try   await  body ( ) 
96-     }  catch  { 
97-       reportIssue ( error,  message ( ) ,  fileID:  fileID,  filePath:  filePath,  line:  line,  column:  column) 
98-       return  nil 
104+   } 
105+ #else 
106+   @_transparent  
107+   @_unsafeInheritExecutor  
108+   public  func  withErrorReporting< R> ( 
109+     _ message:  @autoclosure  ( )  ->  String ?   =  nil , 
110+     to reporters:  [ any  IssueReporter ] ?   =  nil , 
111+     fileID:  StaticString  =  #fileID, 
112+     filePath:  StaticString  =  #filePath, 
113+     line:  UInt  =  #line, 
114+     column:  UInt  =  #column, 
115+     catching body:  ( )  async  throws  ->  R 
116+   )  async  ->  R ?   { 
117+     if  let  reporters { 
118+       return  await  withIssueReporters ( reporters)  { 
119+         do  { 
120+           return  try   await  body ( ) 
121+         }  catch  { 
122+           reportIssue ( 
123+             error, 
124+             message ( ) , 
125+             fileID:  fileID, 
126+             filePath:  filePath, 
127+             line:  line, 
128+             column:  column
129+           ) 
130+           return  nil 
131+         } 
132+       } 
133+     }  else  { 
134+       do  { 
135+         return  try   await  body ( ) 
136+       }  catch  { 
137+         reportIssue ( 
138+           error,  message ( ) ,  fileID:  fileID,  filePath:  filePath,  line:  line,  column:  column) 
139+         return  nil 
140+       } 
99141    } 
100142  } 
101- } 
143+ #endif 
0 commit comments