-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
When running dart migrate, the return values of invocations of emulated function classes (classes that implement call) 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
After running the migration and opting into null-safety, showing that the static type of the call is indeed int and not int?.

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 the var 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,
// The over_react code:
var content = Dom.div()();
// gets migrated to:
ReactElement? content = Dom.div()();Tested and reproduced in Dart SDK versions 2.13.0 and 2.14.0-176.0.dev
