Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer shouldn't recursively flatten futures #32881

Closed
natebosch opened this issue Apr 13, 2018 · 2 comments
Closed

Analyzer shouldn't recursively flatten futures #32881

natebosch opened this issue Apr 13, 2018 · 2 comments
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Milestone

Comments

@natebosch
Copy link
Member

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

@natebosch natebosch added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-strong-mode labels Apr 13, 2018
@leafpetersen leafpetersen added this to the Dart2Stable milestone May 18, 2018
@leafpetersen
Copy link
Member

@bwilkerson I'm going to take this unless you're actively working on it, since it relates to something else I'm fixing.

@bwilkerson
Copy link
Member

Feel free. I haven't started looking at it.

dart-bot pushed a commit that referenced this issue Jun 15, 2018
various kinds of functions.

Closes-bug: #31887
Closes-bug: #30638
Closes-bug: #32233
Closes-bug: #32881
Closes-bug: #31278
Change-Id: I4ebd7e71096d611e189b571ba5de2998dd11c98b
Reviewed-on: https://dart-review.googlesource.com/60300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
@dgrove dgrove closed this as completed Jun 15, 2018
@dgrove dgrove added this to Done in 2.0 language via automation Jun 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
Projects
No open projects
2.0 language
  
Done
Development

No branches or pull requests

4 participants