Skip to content

avoid capturing context in closures that don't need it #45603

Open
@mraleph

Description

@mraleph

In the code below () => 10 would have a parent context capturing v even though it does not need it. We could avoid linking closure context to parent context unless it really needs it.

foo(v) {
  return () {
    print(v);
    return () => 10;
  };
}

Related to flutter/flutter#79605

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions