[expect] Replace @alwaysThrows with Never

Actually, for `Expect.fail`, the return type is kept as `void`, as
changing this to `Never` would apparently change a lot of static
analysis of language and co19 tests. It seems the `@alwaysThrows`
annotation is no longer (or was never) relied upon for static
analysis (usually around dead code analysis).

Bug: https://github.com/dart-lang/sdk/issues/49583
Change-Id: I6d9daaa1d290ab0322a529faaf9574fe83b9cd25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279742
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
Sam Rawlins 2023-01-25 23:02:27 +00:00 committed by Commit Queue
parent 6fa2f50380
commit d5bd015cac
2 changed files with 3 additions and 5 deletions

View file

@ -6,8 +6,6 @@
/// for simple unit-tests.
library expect;
import 'package:meta/meta.dart';
/// Whether the program is running without sound null safety.
bool get hasUnsoundNullSafety => const <Null>[] is List<Object>;
@ -275,7 +273,9 @@ class Expect {
}
// Unconditional failure.
@alwaysThrows
// This function always throws, as [_fail] always throws.
// TODO(srawlins): It would be more correct to change the return type to
// `Never`, which would require refactoring many language and co19 tests.
static void fail(String msg) {
_fail("Expect.fail('$msg')");
}
@ -693,7 +693,6 @@ class Expect {
static String _getMessage(String reason) =>
(reason.isEmpty) ? "" : ", '$reason'";
@alwaysThrows
static Never _fail(String message) {
throw ExpectException(message);
}

View file

@ -13,7 +13,6 @@ environment:
# Use 'any' constraints here; we get our versions from the DEPS file.
dependencies:
meta: any
smith: any
# Use 'any' constraints here; we get our versions from the DEPS file.