Mark new IndexError methods with `@Since`
The new methods `IndexError.withLength` and `IndexError.check`
shouldn't be used by any projects relying on SDK versions prior to
2.19 (since they're not available in older SDKs). Adding
`@Since("2.19")` ensures that once
https://github.com/dart-lang/sdk/issues/34978 is fixed, these methods
will trigger a lint to fire if they're used in a project targeting an
older SDK version.
Change-Id: I5b43ffba2def391b84a4f3f7d8eecaae766e7656
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269142
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart
index a88d49d..b9641ad 100644
--- a/sdk/lib/core/errors.dart
+++ b/sdk/lib/core/errors.dart
@@ -437,6 +437,7 @@
/// The [length] is the length of [indexable] at the time of the error.
///
/// The message is used as part of the string representation of the error.
+ @Since("2.19")
IndexError.withLength(int invalidValue, this.length,
{this.indexable, String? name, String? message})
: super.value(invalidValue, name, message ?? "Index out of range");
@@ -459,6 +460,7 @@
/// The [message], if provided, is included in the error string.
///
/// Returns [index] if it is a valid index.
+ @Since("2.19")
static int check(int index, int length,
{Object? indexable, String? name, String? message}) {
// Comparing with `0` as receiver produces better dart2js type inference.