mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
b7567b1799
Several unusual constructs that lead to unreachable code are now recognized by flow analysis: - Control flow after an expression of the form `e ?? other` or `e ??= other`, where `e` has static type `Null` and `other` has static type `Never`, is considered unreachable. - Control flow predicated on an expression of the form `e is Never` evaluating to `true` is considered unreachable. - Control flow predicated on an expression of the form `e is! Never` evaluating to `false` is considered unreachable. - Control flow on the RHS of a null-aware access such as `e?.property...`, `e?.property = ...` or `e?.method(...)`, where `e` has static type `Null`, is considered unreachable (Note: this can arise in the presence of extension methods). Previously, these behaviors only took effect if `e` was a reference to a local variable. Note: the change to `regress/issue_31180` is because I’ve corrected the behavior of implicit temporary variables to not undergo a type change from `Null` to `dynamic`, so the dead code part of `null?[1]` is now erroneous. (I had to make this change in order for the last bullet above to work properly; without it, the type change to `dynamic` prevents flow analysis from recognizing that the code to the right of `?.` is unreachable.) There's no behavioral change to correct code, but I've captured the behavioral change to incorrect code in `tests/language_2/null_aware/null_aware_index_on_null_error_test.dart`. Bug: https://github.com/dart-lang/sdk/issues/49635 Change-Id: I8b24b3b040a34f897c0b61dcb9bd105be6d0af6d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251280 Commit-Queue: Paul Berry <paulberry@google.com> Reviewed-by: Bob Nystrom <rnystrom@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> |
||
---|---|---|
.. | ||
access_runtime_test.dart | ||
access_test.dart | ||
assignment_runtime_test.dart | ||
assignment_test.dart | ||
conditional_access_helper.dart | ||
dynamic_test.dart | ||
increment_decrement_runtime_test.dart | ||
increment_decrement_test.dart | ||
index_this_null_aware_equals_test.dart | ||
invocation_runtime_test.dart | ||
invocation_test.dart | ||
null_aware_index_on_null_test.dart | ||
null_shortening_test.dart | ||
opt_test.dart | ||
prefix_not_shortening_test.dart |