Document and test additional breaking change.

Breaking change https://github.com/dart-lang/sdk/issues/49635 had a
slightly larger effect than I previously understood.  This change
documents the additional effect and adds a test that would have caught
it.

Bug: https://github.com/dart-lang/sdk/issues/49635
Change-Id: I40e9434a7fb87ff00d71b454239e4cadf197a285
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256880
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
Paul Berry 2022-09-08 16:05:05 +00:00 committed by Commit Bot
parent 0b71ae22fa
commit 7eab5ef808
2 changed files with 26 additions and 0 deletions

View file

@ -24,6 +24,9 @@
Previously, these behaviors only took effect if `e` was a reference to a local
variable.
Additionally, a type test of the form `v is Never` (where `v` is a local
variable) no longer promotes `v` to type `Never`.
[#49635]: https://github.com/dart-lang/sdk/issues/49635
### Libraries

View file

@ -0,0 +1,23 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// 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.
// This tests changes around promotion to `Never` that were made as part of
// https://dart-review.googlesource.com/c/sdk/+/251280
// (https://github.com/dart-lang/sdk/issues/49635): a type test of `variable is
// Never` no longer promotes the type of `variable` to `Never`.
void f(int i) {
if (i is Never) {
i.isEven;
i.abs();
i.bogus();
//^^^^^
// [analyzer] COMPILE_TIME_ERROR.UNDEFINED_METHOD
// [cfe] The method 'bogus' isn't defined for the class 'int'.
}
}
main() {
f(0);
}