mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 02:27:39 +00:00
454ab91576
Summary: Previously, when a function parameter was captured both in an initializer and in the body of a constructor, we would create two contexts: one created in a local initializer and used by other initializers, and another in the body of the function. This is incorrect, as it means that changes to the parameter in the initializer's closure won't be visible in the body. Now, to work around this problem we re-use the context created for the initializers in the body of the constructor by moving the body into a new constructor, and redirecting the original constructor to that one, passing the context as an additional argument. This dance is necessary because local initializers aren't visible in the body of a constructor. Test Plan: A few of the existing closure conversion tests were changed or fixed by this revision. We also modify the 'closure_in_initializer.dart' test to hit this case directly. R=dmitryas@google.com Reviewers: dmitryas@google.com Review-Url: https://codereview.chromium.org/2991853002 . |
||
---|---|---|
.. | ||
capture_closure.dart | ||
capture_closure.dart.expect | ||
capture_closure_parameter.dart | ||
capture_closure_parameter.dart.expect | ||
capture_this.dart | ||
capture_this.dart.expect | ||
catch.dart | ||
catch.dart.expect | ||
closure_in_constructor.dart | ||
closure_in_constructor.dart.expect | ||
closure_in_initializer.dart | ||
closure_in_initializer.dart.expect | ||
closure_in_initializer_closure.dart | ||
closure_in_initializer_closure.dart.expect | ||
closures.dart | ||
closures.dart.expect | ||
contexts_in_field_initializers.dart | ||
contexts_in_field_initializers.dart.expect | ||
contexts_in_super_initializers.dart | ||
contexts_in_super_initializers.dart.expect | ||
field.dart | ||
field.dart.expect | ||
for_in_closure.dart | ||
for_in_closure.dart.expect | ||
for_loop.dart | ||
for_loop.dart.expect | ||
for_variable_capture_test.dart | ||
for_variable_capture_test.dart.expect | ||
instance_tear_off.dart | ||
instance_tear_off.dart.expect | ||
named_closure.dart | ||
named_closure.dart.expect | ||
non_void_context.dart | ||
non_void_context.dart.expect | ||
README.md | ||
static_tear_off.dart | ||
static_tear_off.dart.expect | ||
uncaptured_for_in_loop.dart | ||
uncaptured_for_in_loop.dart.expect |
Running tests
export DART_AOT_SDK=.../xcodebuild/DerivedSources/DebugX64/patched_sdk
dart -c --packages=.packages package:testing/src/run_tests.dart test/closures/testing.json