Migration tool could understand manually lazily initialized fields #44109
Labels
area-migration (deprecated)
Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
It would be great if the tool recognized a manually lazily initialized field:
In this case , the tool makes
_i
nullable, and often makesget i
nullable as well (depending on how the body is structured).The big problems come when
get i
is considered nullable, when it should be non-nullable. I can generally force non-nullability by hinting/*late final*/ int _i;
, but I think this would make illegal code (or just warnings) w.r.t._i ??= ...;
. The fix that I would do as a human are, perhaps strangely, to flip the field_i
and the getteri
, to use lazy initialization:But I'm not sure that this is what we want the tool to do... sometimes the field and the getter are not adjacent class elements.
This all holds for top-level variables too.
The text was updated successfully, but these errors were encountered: