Migrate tool incorrectly treats result of emulated function calls as nullable #46263
Labels
area-migration (deprecated)
Deprecated: this label is no longer actively used (was: issues with the `dart migrate` tool).
When running
dart migrate
, the return values of invocations of emulated function classes (classes that implementcall
) are incorrectly treated as nullable.This only happens when calling emulated functions directly but not when using
.call(...)
, and also doesn't affect normal function types.As a result, functions that return the result of these calls and variables that are initialized with the result of these calls are marked as nullable.
Reduced test case: https://gist.github.com/greglittlefield-wf/3b8cb36ae407a8485b1f5029db0e9c62
Screenshot of migration tool
After running the migration and opting into null-safety, showing that the static type of the call is indeed
int
and notint?
.The function return value case can be worked around by adding
/*!*/
hints comments, but unfortunately there's nothing that can prevent the tool from updating thevar
case.We also have many of these types of calls in our libraries (via the invocation of OverReact UiProps classes as builders), so having to manually add the hints and update the typings on variables seems like it would be pretty tedious.
For example,
Tested and reproduced in Dart SDK versions 2.13.0 and 2.14.0-176.0.dev
The text was updated successfully, but these errors were encountered: