-
Notifications
You must be signed in to change notification settings - Fork 230
Closed
Labels
nnbdNNBD related issuesNNBD related issues
Description
The following program results in a variable of type int containing null (as implemented on the VM, and I believe as currently specified):
Future<int>? foo() async {
return Future<int?>.value(null) as dynamic;
}
void main() async {
Future<int>? f = foo();
if (f != null) {
await f.then((x) => print(x.isEven));
}
}The issue is that flatten(Future<int>?) = int?, and so the dynamic semantics is specified to check if the returned value is Future<int?> (which here it is) and if so use the contents of the future to complete the return future, which has an incompatible type.
I believe we need to either use something like the future value type that @eernstg has proposed, or else possibly just disallow these odd return types for asynchronous functions.
Metadata
Metadata
Assignees
Labels
nnbdNNBD related issuesNNBD related issues