Skip to content

Commit

Permalink
Lock "unreachable via this" tests to language version 3.1.
Browse files Browse the repository at this point in the history
When these tests were written
(https://dart-review.googlesource.com/c/sdk/+/178880), Dart did not
support field promotion. I was getting ready to add "why not promoted"
logic to flow analysis so that if a user tried and failed to promote a
field, and received an assignability error as a result, they would
receive a helpful error message explaining that field promotion was
not supported.

In order to generate this error message, flow analysis would have to
start keeping track of some *counterfactual* promoted types,
indicating what the type of certain expressions *would have been* if
field promotion had been supported. It was important to make sure that
these counterfactual promoted types were only used for error message
generation, and didn't actually change Dart semantics. So I wrote
these tests to help lock down the existing (non-promotion) behavior.

When field promotion was actually implemented in Dart 3.2, these tests
should have been given `@dart=3.1` annotations, since their purpose
was to validate the correct behavior of the implementation in
situations where field promotion *wasn't* enabled. I should have been
prompted to do this by a test failure, because when I enabled field
promotion by default in Dart 3.2, the behavior of the tests should
have changed. However, because of
dart-lang/language#4127, the behavior didn't
change, so I didn't notice that these tests needed updating.

Now, I'm getting ready to fix
dart-lang/language#4127, so in order to
prepare for that, I need to give these tests the proper `@dart=3.1`
annotations.

Bug: dart-lang/language#4127
Change-Id: I59ad1eef7b01ccedcc8fb99e070a05273ac365e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/389781
Reviewed-by: Kallen Tu <[email protected]>
Commit-Queue: Paul Berry <[email protected]>
  • Loading branch information
stereotype441 authored and Commit Queue committed Oct 15, 2024
1 parent 4f01b04 commit caba043
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=3.1

/// This test verifies that `is` and `==` tests performed on a property get of
/// `this` do not lead to code being considered unreachable. (In principle, we
/// could soundly mark some such code as unreachable, but we have decided not to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

// @dart=3.1

/// This test verifies that `is` and `==` tests performed on a property get of a
/// variable do not lead to code being considered unreachable. (In principle,
/// we could soundly mark some such code as unreachable, but we have decided not
Expand Down

0 comments on commit caba043

Please sign in to comment.