Migration tool should assume assertions enabled. #44292
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
I found this issue while investigating #44280.
Repro steps:
\
to/
inexample/pubspec.yaml
to work around Pubspec apparently allows\
as path separator under windows but not linux pub#2769.flutter pub upgrade
.--skip-import-check
.Observed result:
lib/get_it_impl.dart
lines 329-332 (at the end of the method_GetItImplementation.get
) are migrated like this:_GetItImplementation.get
is marked as nullable, and consequently, the return type ofGetIt.get
is marked as nullable.Expected result:
assert(instance is T, ...);
should be sufficient to indicate to the migration tool thatinstance
is expected to have typeT
, therefore no?
should be added to the return statement.This is yet another facet of #40566; since we're currently using flow analysis in the migration tool's edge builder, and flow analysis conservatively assumes the user might be running with assertions disabled, assertions like this aren't taken into account when building the nullability graph. But really, they should be taken into account, because the purpose of the edge builder is to build a nullability graph that reflects the user's intention about what should be nullable and what shouldn't be; and assertions are a valuable source of information about intention regardless of whether they get enabled at runtime or not.
The text was updated successfully, but these errors were encountered: