From 81b137d8fe7c68fd524605c0f3e62800faca7ea6 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Mon, 2 Jan 2023 16:14:08 +0000 Subject: [PATCH] [3.0 alpha] Remove deprecated `BidirectionalIterator`. Requires releasing `package:quiver` 3.2.0 so Flutter can upgrade to that. Change-Id: Ibd9acc5fa11a67ca50d06172dfe0f9175b240522 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276741 Commit-Queue: Lasse Nielsen Reviewed-by: Aske Simon Christensen --- CHANGELOG.md | 6 +++++- .../main.dart.strong.expect | 1 - .../main.dart.strong.transformed.expect | 1 - .../main.dart.weak.expect | 1 - .../main.dart.weak.outline.expect | 1 - .../main.dart.weak.transformed.expect | 1 - .../export_core.yaml.world.2.expect | 1 - .../export_core.yaml.world.3.expect | 1 - runtime/tools/dartfuzz/gen_type_table.dart | 1 - sdk/lib/core/iterable.dart | 19 ------------------- sdk/lib/core/string.dart | 10 +++++++++- 11 files changed, 14 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e013bd16221..b81eedb0e49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,9 @@ ways instead, possibly with a StackOverflowError. - Removed the deprecated [`NoSuchMethodError`][] default constructor. Use the [`NoSuchMethodError.withInvocation`][] named constructor instead. + - Removed the deprecated [`BidirectionalIterator`][] class. + Existing bidirectional iterators can still work, they just don't have + a shared supertype locking them to a specific name for moving backwards. [#49529]: https://github.com/dart-lang/sdk/issues/49529 [`List.filled`]: https://api.dart.dev/stable/2.18.6/dart-core/List/List.filled.html @@ -54,6 +57,7 @@ [`NullThrownError`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/NullThrownError-class.html [`AbstractClassInstantiationError`]: https://api.dart.dev/stable/2.18.3/dart-core/AbstractClassInstantiationError-class.html [`CyclicInitializationError`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/CyclicInitializationError-class.html +[`BidirectionalIterator`]: https://api.dart.dev/dev/2.19.0-430.0.dev/dart-core/BidirectionalIterator-class.html #### `dart:async` @@ -68,7 +72,7 @@ #### `dart:developer` - **Breaking change** [#49529][]: - - Removed the deprecated [`MAX_USER_TAGS`][] constant. + - Removed the deprecated [`MAX_USER_TAGS`][] constant. Use [`maxUserTags`][] instead. - Callbacks passed to `registerExtension` will be run in the zone from which they are registered. diff --git a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.expect b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.expect index 67410f4875f..af63181c2f5 100644 --- a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.expect +++ b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.expect @@ -121,7 +121,6 @@ additionalExports = (core::Deprecated, core::int, core::Invocation, core::Iterable, - core::BidirectionalIterator, core::Iterator, core::List, core::Map, diff --git a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.transformed.expect b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.transformed.expect index 28e4d7820ee..a01af775a8e 100644 --- a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.strong.transformed.expect @@ -117,7 +117,6 @@ additionalExports = (core::Deprecated, core::int, core::Invocation, core::Iterable, - core::BidirectionalIterator, core::Iterator, core::List, core::Map, diff --git a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.expect b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.expect index 67410f4875f..af63181c2f5 100644 --- a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.expect +++ b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.expect @@ -121,7 +121,6 @@ additionalExports = (core::Deprecated, core::int, core::Invocation, core::Iterable, - core::BidirectionalIterator, core::Iterator, core::List, core::Map, diff --git a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.outline.expect b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.outline.expect index ed19572c088..a1ec6562d8e 100644 --- a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.outline.expect +++ b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.outline.expect @@ -56,7 +56,6 @@ additionalExports = (core::Deprecated, core::int, core::Invocation, core::Iterable, - core::BidirectionalIterator, core::Iterator, core::List, core::Map, diff --git a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.transformed.expect b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.transformed.expect index 28e4d7820ee..a01af775a8e 100644 --- a/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/general/error_export_from_dill/main.dart.weak.transformed.expect @@ -117,7 +117,6 @@ additionalExports = (core::Deprecated, core::int, core::Invocation, core::Iterable, - core::BidirectionalIterator, core::Iterator, core::List, core::Map, diff --git a/pkg/front_end/testcases/incremental/export_core.yaml.world.2.expect b/pkg/front_end/testcases/incremental/export_core.yaml.world.2.expect index b9a075c90da..65de26d92d3 100644 --- a/pkg/front_end/testcases/incremental/export_core.yaml.world.2.expect +++ b/pkg/front_end/testcases/incremental/export_core.yaml.world.2.expect @@ -11,7 +11,6 @@ additionalExports = (asy::Future, core::Comparator, core::ArgumentError, core::AssertionError, - core::BidirectionalIterator, core::BigInt, core::Comparable, core::ConcurrentModificationError, diff --git a/pkg/front_end/testcases/incremental/export_core.yaml.world.3.expect b/pkg/front_end/testcases/incremental/export_core.yaml.world.3.expect index 79de28b6941..835e454bfc8 100644 --- a/pkg/front_end/testcases/incremental/export_core.yaml.world.3.expect +++ b/pkg/front_end/testcases/incremental/export_core.yaml.world.3.expect @@ -11,7 +11,6 @@ additionalExports = (asy::Future, core::Comparator, core::ArgumentError, core::AssertionError, - core::BidirectionalIterator, core::BigInt, core::Comparable, core::ConcurrentModificationError, diff --git a/runtime/tools/dartfuzz/gen_type_table.dart b/runtime/tools/dartfuzz/gen_type_table.dart index 2c2a1896b53..400fefdb9bf 100644 --- a/runtime/tools/dartfuzz/gen_type_table.dart +++ b/runtime/tools/dartfuzz/gen_type_table.dart @@ -1394,7 +1394,6 @@ void visitCompilationUnit( (classElement.name == 'StackTrace') || (classElement.name == 'NoSuchMethodError') || (classElement.name == 'Comparable') || - (classElement.name == 'BidirectionalIterator') || (classElement.name == 'Iterator') || (classElement.name == 'Stopwatch') || (classElement.name == 'Finalizer') || diff --git a/sdk/lib/core/iterable.dart b/sdk/lib/core/iterable.dart index 1960f2980c6..be894489a1d 100644 --- a/sdk/lib/core/iterable.dart +++ b/sdk/lib/core/iterable.dart @@ -822,22 +822,3 @@ class _GeneratorIterable extends ListIterable { /// Helper function used as default _generator function. static int _id(int n) => n; } - -/// An [Iterator] that allows moving backwards as well as forwards. -/// -/// Deprecation note: This interface has turned out to not be -/// valuable as a general reusable interface. There is still only -/// one class implementing it, [RuneIterator], and at least one other -/// bidirectional iterator preferred a different name than `movePrevious` -/// for the other direction. -/// As such, this interface does not carry its own weight, and will be -/// removed in a later release. -@Deprecated("Use the implementing class directly") -abstract class BidirectionalIterator implements Iterator { - /// Move back to the previous element. - /// - /// Returns true and updates [current] if successful. Returns false - /// and updates [current] to an implementation defined state if there is no - /// previous element - bool movePrevious(); -} diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart index 694ce732025..b4c80788745 100644 --- a/sdk/lib/core/string.dart +++ b/sdk/lib/core/string.dart @@ -799,7 +799,7 @@ int _combineSurrogatePair(int start, int end) { } /// [Iterator] for reading runes (integer Unicode code points) of a Dart string. -class RuneIterator implements BidirectionalIterator { +class RuneIterator implements Iterator { /// String being iterated. final String string; @@ -906,6 +906,10 @@ class RuneIterator implements BidirectionalIterator { return string.substring(_position, _nextPosition); } + /// Move to the next code point. + /// + /// Returns `true` and updates [current] if there is a next code point. + /// Returns `false` otherwise, and then there is no current code point. bool moveNext() { _position = _nextPosition; if (_position == string.length) { @@ -927,6 +931,10 @@ class RuneIterator implements BidirectionalIterator { return true; } + /// Move back to the previous code point. + /// + /// Returns `true` and updates [current] if there is a previous code point. + /// Returns `false` otherwise, and then there is no current code point. bool movePrevious() { _nextPosition = _position; if (_position == 0) {