dart-sdk/tests/language/null_aware
Paul Berry b7567b1799 Flag additional code as unreachable due to types Null and Never.
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>
2022-08-22 16:50:19 +00:00
..
access_runtime_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
access_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
assignment_runtime_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
assignment_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
conditional_access_helper.dart
dynamic_test.dart
increment_decrement_runtime_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
increment_decrement_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
index_this_null_aware_equals_test.dart
invocation_runtime_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
invocation_test.dart Issue 48004. Report when null-aware operator is used on type. 2022-05-29 19:03:15 +00:00
null_aware_index_on_null_test.dart Flag additional code as unreachable due to types Null and Never. 2022-08-22 16:50:19 +00:00
null_shortening_test.dart
opt_test.dart
prefix_not_shortening_test.dart