@@ -255,6 +255,33 @@ def __init__(self) -> None:
255255 self .revealed_types = defaultdict (list )
256256
257257
258+ def yield_uselessness_error_infos (self ) -> Iterator [tuple [str , Context , ErrorCode ]]:
259+ """Report only those `unreachable`, `redundant-expr`, and `redundant-casts`
260+ errors that could not be ruled out in any iteration step."""
261+
262+ persistent_uselessness_errors = set ()
263+ for candidate in set (chain (* self .uselessness_errors )):
264+ if all (
265+ (candidate in errors ) or (candidate [2 ] in lines )
266+ for errors , lines in zip (self .uselessness_errors , self .unreachable_lines )
267+ ):
268+ persistent_uselessness_errors .add (candidate )
269+ for error_info in persistent_uselessness_errors :
270+ context = Context (line = error_info [2 ], column = error_info [3 ])
271+ context .end_line = error_info [4 ]
272+ context .end_column = error_info [5 ]
273+ yield error_info [1 ], context , error_info [0 ]
274+
275+ def yield_revealed_type_infos (self ) -> Iterator [tuple [Type , Context ]]:
276+ """Yield all types revealed in at least one iteration step."""
277+
278+ for note_info , types in self .revealed_types .items ():
279+ context = Context (line = note_info [0 ], column = note_info [1 ])
280+ context .end_line = note_info [2 ]
281+ context .end_column = note_info [3 ]
282+ yield make_simplified_union (types ), context
283+
284+
258285class IterationErrorWatcher (ErrorWatcher ):
259286 """Error watcher that filters and separately collects `unreachable` errors,
260287 `redundant-expr` and `redundant-casts` errors, and revealed types when analysing
@@ -297,35 +324,6 @@ def on_error(self, file: str, info: ErrorInfo) -> bool:
297324
298325 return super ().on_error (file , info )
299326
300- def yield_error_infos (self ) -> Iterator [tuple [str , Context , ErrorCode ]]:
301- """Report only those `unreachable`, `redundant-expr`, and `redundant-casts`
302- errors that could not be ruled out in any iteration step."""
303-
304- persistent_uselessness_errors = set ()
305- iter_errors = self .iteration_dependent_errors
306- for candidate in set (chain (* iter_errors .uselessness_errors )):
307- if all (
308- (candidate in errors ) or (candidate [2 ] in lines )
309- for errors , lines in zip (
310- iter_errors .uselessness_errors , iter_errors .unreachable_lines
311- )
312- ):
313- persistent_uselessness_errors .add (candidate )
314- for error_info in persistent_uselessness_errors :
315- context = Context (line = error_info [2 ], column = error_info [3 ])
316- context .end_line = error_info [4 ]
317- context .end_column = error_info [5 ]
318- yield error_info [1 ], context , error_info [0 ]
319-
320- def yield_note_infos (self ) -> Iterator [tuple [Type , Context ]]:
321- """Yield all types revealed in at least one iteration step."""
322-
323- for note_info , types in self .iteration_dependent_errors .revealed_types .items ():
324- context = Context (line = note_info [0 ], column = note_info [1 ])
325- context .end_line = note_info [2 ]
326- context .end_column = note_info [3 ]
327- yield make_simplified_union (types ), context
328-
329327
330328class Errors :
331329 """Container for compile errors.
0 commit comments