Closed
Description
I hit some code that has no errors or warnings with dartanalyzer --strong
but has parse errors with dart --preview-dart-2
. Here's a contrived demo:
import 'dart:async';
void main() async {
print(await stuff());
}
Future<String> stuff() async {
return moreStuff<Future<String>>(new Future.value('stuff'));
}
Future<T> moreStuff<T>(T value) async => value;
Running with dart --preview-dart-2
gives:
file:///tmp/nested_futures.dart:8:10: Error: A value of type 'dart.async::Future<dart.async::Future<dart.core::String>>' can't be assigned to a variable of type 'dart.async::FutureOr<dart.core::String>'.
Try changing the type of the left hand side, or casting the right hand side to 'dart.async::FutureOr<dart.core::String>'.
return moreStuff<Future<String>>(new Future.value('stuff'));
^
file:///tmp/nested_futures.dart:8:10: Error: A value of type 'dart.async::Future<dart.async::Future<dart.core::String>>' can't be assigned to a variable of type 'dart.async::FutureOr<dart.core::String>'.
Try changing the type of the left hand side, or casting the right hand side to 'dart.async::FutureOr<dart.core::String>'.
return moreStuff<Future<String>>(new Future.value('stuff'));
^
Real world code is fixed in dart-lang/test#810