Consider adding "why promoted" context information for warnings/errors caused by type promotion #45332
Labels
area-devexp
Developer experience items (DevTools, IDEs, analysis server, completions, refactorings, ...).
devexp-ux
legacy-area-front-end
Legacy: Use area-dart-model instead.
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
Inspired by this comment: dart-lang/language#1523 (comment)
Consider the following code:
Note that the user migrated this code incorrectly from a pre-null-safety version: at (1), they should have used
x as int?
to preserve the behavior thatnull
is allowed.Currently the analyzer generates the following warning at the line marked (2):
Based on this warning, it's not easy to figure out that the mistake was in the
as
expression at (1). A possible way to help this would be to add context information to the warning explaining the reason the operand can't be null: because it was promoted at line (1).It should be possible to do this in a similar way to how we are adding "why not promoted" context information (#44897).
The text was updated successfully, but these errors were encountered: