Skip to content

Commit

Permalink
Mark new IndexError methods with @Since
Browse files Browse the repository at this point in the history
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
#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 <[email protected]>
Commit-Queue: Paul Berry <[email protected]>
  • Loading branch information
stereotype441 authored and Commit Queue committed Nov 11, 2022
1 parent bdd37d0 commit bd15d09
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sdk/lib/core/errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ class IndexError extends ArgumentError implements RangeError {
/// 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");
Expand All @@ -459,6 +460,7 @@ class IndexError extends ArgumentError implements RangeError {
/// 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.
Expand Down

0 comments on commit bd15d09

Please sign in to comment.