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

function inline with simple async code #59783

Open
stephane-archer opened this issue Dec 20, 2024 · 0 comments
Open

function inline with simple async code #59783

stephane-archer opened this issue Dec 20, 2024 · 0 comments
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@stephane-archer
Copy link

stephane-archer commented Dec 20, 2024

function inline with simple async code

Future<void> foo(int i, int j) async{
  await Future.delayed(const Duration(seconds: 1));
  print(i);
  print(j);
}

Future<void> main() async {
  int i = 1;
  int j = 1;
  await foo(i, j);
}

inline foo result:

Future<void> main() async {
  int i = 1;
  int j = 1;
  await (int i, int j) async{
    await Future.delayed(const Duration(seconds: 1));
    print(i);
    print(j);
  }(i, j);
}

expected code:

Future<void> main() async {
  int i = 1;
  int j = 1;
  await Future.delayed(const Duration(seconds: 1));
  print(i);
  print(j);
}

this pattern is valid but unnecessary it creates a lambda rather than inlining
await (int i, int j) async{ ................ }(i, j);

@stephane-archer stephane-archer added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Dec 20, 2024
@bwilkerson bwilkerson added analyzer-quick-fix P2 A bug or feature request we're likely to work on labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

2 participants