Skip to content

function inline with simple async code #59783

Open
@stephane-archer

Description

@stephane-archer

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-quick-fixIssues with analysis server (quick) fixes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions