Make RegExpMatch.pattern have type RegExp.

It's always a RegExp, so it's a safe change.
It's also a very, very rarely used property,
since nobody ever noticed that it wasn't typed optimally.

Tested: Type change of getter to actual type of value. No new test.
CoreLibraryReviewExempt: Aske is out.
Change-Id: Ifb560a80c3cdb05be0164c593383539dc10ec0dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267961
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
Lasse R.H. Nielsen 2023-04-04 20:34:36 +00:00 committed by Commit Queue
parent 2f71556f8b
commit f51e9d1dda
6 changed files with 7 additions and 4 deletions

View file

@ -31,6 +31,7 @@
#### `dart:core`
- Added `bool.parse` and `bool.tryParse` static methods.
- Added `DateTime.timestamp()` constructor to get current time as UTC.
- The type of `RegExpMatch.pattern` is now `RegExp`, not just `Pattern`.
- **Breaking change** [#49529][]:
- Removed the deprecated `List` constructor, as it wasn't null safe.

View file

@ -180,7 +180,7 @@ class JSSyntaxRegExp implements RegExp {
}
class _MatchImplementation implements RegExpMatch {
final Pattern pattern;
final RegExp pattern;
// Contains a JS RegExp match object that is an Array with extra "index" and
// "input" properties. The array contains Strings but the values at indices
// related to capture groups can be undefined.

View file

@ -168,7 +168,7 @@ class JSSyntaxRegExp implements RegExp {
}
class _MatchImplementation implements RegExpMatch {
final Pattern pattern;
final RegExp pattern;
// Contains a JS RegExp match object.
// It is an Array of String values with extra 'index' and 'input' properties.
// If there were named capture groups, there will also be an extra 'groups'

View file

@ -117,7 +117,7 @@ class _RegExpMatch implements RegExpMatch {
int get groupCount => _regexp._groupCount;
Pattern get pattern => _regexp;
RegExp get pattern => _regexp;
String? namedGroup(String name) {
var idx = _regexp._groupNameIndex(name);

View file

@ -163,7 +163,7 @@ class JSSyntaxRegExp implements RegExp {
}
class _MatchImplementation implements RegExpMatch {
final Pattern pattern;
final RegExp pattern;
// Contains a JS RegExp match object.
// It is an Array of String values with extra 'index' and 'input' properties.
// If there were named capture groups, there will also be an extra 'groups'

View file

@ -483,4 +483,6 @@ abstract interface class RegExpMatch implements Match {
/// The names of the named capture groups of [pattern].
Iterable<String> get groupNames;
RegExp get pattern;
}