diff --git a/CHANGELOG.md b/CHANGELOG.md index ee06d0472d9..45c048b6b39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,36 +61,13 @@ a shared supertype locking them to a specific name for moving backwards. - **Breaking change when migrating code to Dart 3.0**: - Some changes to platform libraries only affect code when that code is migrated + Some changes to platform libraries only affect code when it is migrated to language version 3.0. - - The `Function` type can no longer be implemented, extended or mixed in. + - The `Function` type can no longer be implemented. Since Dart 2.0 writing `implements Function` has been allowed for backwards compatibility, but it has not had any effect. - In Dart 3.0, the `Function` type is `final` and cannot be subtyped, - preventing code from mistakenly assuming it works. - - The following declarations can only be implemented, not extended: - * `Comparable` - * `Exception` - * `Iterator` - * `Pattern` - * `Match` - * `RegExp` - * `RegExpMatch` - * `StackTrace` - * `StringSink` - None of these declarations contained any implementation to inherit, - and are marked as `interface` to signify that they are only intended - as interfaces. - - The following declarations can no longer be implemented or extended: - * `MapEntry` - * `OutOfMemoryError` - * `StackOverflowError` - * `Expando` - * `WeakReference` - * `Finalizer` - The `MapEntry` value class is restricted to enable later optimizations. - The remaining classes are tightly coupled to the platform and not - intended to be subclassed or implemented. + In Dart 3.0, the `Function` type is `final` and cannot be implemented + by class-modifier aware code. [#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 diff --git a/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart b/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart index e5921816785..ecf1044f45f 100644 --- a/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart +++ b/pkg/_fe_analyzer_shared/lib/src/util/link_implementation.dart @@ -31,7 +31,7 @@ class LinkIterator implements Iterator { typedef T Transformation(S input); -class MappedLinkIterator implements Iterator { +class MappedLinkIterator extends Iterator { Transformation _transformation; Link _link; T? _current; diff --git a/pkg/compiler/lib/src/universe/class_set.dart b/pkg/compiler/lib/src/universe/class_set.dart index ea98bdec49f..acb9ae9139e 100644 --- a/pkg/compiler/lib/src/universe/class_set.dart +++ b/pkg/compiler/lib/src/universe/class_set.dart @@ -967,7 +967,7 @@ class SubtypesIterable extends IterableBase { } /// Iterator for the subtypes in a [ClassSet]. -class SubtypesIterator implements Iterator { +class SubtypesIterator extends Iterator { final SubtypesIterable iterable; Iterator? elements; Iterator? hierarchyNodes; diff --git a/pkg/compiler/test/inference/powerset_bits3_test.dart b/pkg/compiler/test/inference/powerset_bits3_test.dart index f0bfd2a47c5..655de6a8347 100644 --- a/pkg/compiler/test/inference/powerset_bits3_test.dart +++ b/pkg/compiler/test/inference/powerset_bits3_test.dart @@ -13,19 +13,19 @@ import '../helpers/element_lookup.dart'; import 'package:compiler/src/util/memory_compiler.dart'; const String CODE = """ -class A implements Comparable { +class A extends Comparable { int compareTo(x) { return 0; } } -class B implements Comparable { +class B extends Comparable { int compareTo(x) { return 0; } } -class C implements Comparable { +class C extends Comparable { int compareTo(x) { return 0; } } -class D implements Comparable { +class D extends Comparable { int compareTo(x) { return 0; } } -class E implements Comparable { +class E extends Comparable { int compareTo(x) { return 0; } } diff --git a/pkg/front_end/testcases/incremental/issue_32366.yaml b/pkg/front_end/testcases/incremental/issue_32366.yaml index 4108b175fb0..3fc46c3feb0 100644 --- a/pkg/front_end/testcases/incremental/issue_32366.yaml +++ b/pkg/front_end/testcases/incremental/issue_32366.yaml @@ -8,7 +8,7 @@ worlds: - entry: main.dart sources: main.dart: | - abstract class AIterator implements Iterator { + abstract class AIterator extends Iterator { } class Foo { final a; @@ -25,7 +25,7 @@ worlds: errors: true sources: main.dart: | - abstract class BIterator implements Iterator { + abstract class BIterator extends Iterator { } class Foo { final a kjsdf ksjdf ; diff --git a/pkg/front_end/testcases/incremental/issue_32366.yaml.world.1.expect b/pkg/front_end/testcases/incremental/issue_32366.yaml.world.1.expect index 3ac341d4355..bc95a7c5fcf 100644 --- a/pkg/front_end/testcases/incremental/issue_32366.yaml.world.1.expect +++ b/pkg/front_end/testcases/incremental/issue_32366.yaml.world.1.expect @@ -1,9 +1,9 @@ main = main::main; library from "org-dartlang-test:///main.dart" as main { - abstract class AIterator extends dart.core::Object implements dart.core::Iterator { + abstract class AIterator extends dart.core::Iterator { synthetic constructor •() → main::AIterator - : super dart.core::Object::•() + : super dart.core::Iterator::•() ; } class Foo extends dart.core::Object { diff --git a/pkg/front_end/testcases/incremental/issue_32366.yaml.world.2.expect b/pkg/front_end/testcases/incremental/issue_32366.yaml.world.2.expect index b9a726ac08a..84dceba1628 100644 --- a/pkg/front_end/testcases/incremental/issue_32366.yaml.world.2.expect +++ b/pkg/front_end/testcases/incremental/issue_32366.yaml.world.2.expect @@ -30,9 +30,9 @@ library from "org-dartlang-test:///main.dart" as main { // ^ // - abstract class BIterator extends dart.core::Object implements dart.core::Iterator { + abstract class BIterator extends dart.core::Iterator { synthetic constructor •() → main::BIterator - : super dart.core::Object::•() + : super dart.core::Iterator::•() ; } class Foo extends dart.core::Object { diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart b/pkg/front_end/testcases/inference/try_catch_promotion.dart index abdc8f392c4..17f1e21d1ce 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart @@ -11,7 +11,7 @@ class C {} class D extends C {} -class E implements StackTrace {} +class E extends StackTrace {} void test(void f()) { try { diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.expect index cba89691040..c5c1336ed8c 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.expect @@ -29,11 +29,12 @@ class D extends self::C { : super self::C::•() ; } -class E extends core::Object implements core::StackTrace { +class E extends core::StackTrace { synthetic constructor •() → self::E* - : super core::Object::•() + : super core::StackTrace::•() ; abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod + abstract member-signature method toString() → core::String*; -> core::StackTrace::toString abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -41,7 +42,6 @@ class E extends core::Object implements core::StackTrace { abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::== abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode - abstract member-signature method toString() → core::String*; -> core::Object::toString abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType } static method test(() →* void f) → void { diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.transformed.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.transformed.expect index cba89691040..c5c1336ed8c 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.transformed.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.strong.transformed.expect @@ -29,11 +29,12 @@ class D extends self::C { : super self::C::•() ; } -class E extends core::Object implements core::StackTrace { +class E extends core::StackTrace { synthetic constructor •() → self::E* - : super core::Object::•() + : super core::StackTrace::•() ; abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod + abstract member-signature method toString() → core::String*; -> core::StackTrace::toString abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -41,7 +42,6 @@ class E extends core::Object implements core::StackTrace { abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::== abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode - abstract member-signature method toString() → core::String*; -> core::Object::toString abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType } static method test(() →* void f) → void { diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline.expect index df1115e37a9..654304607db 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline.expect @@ -5,7 +5,7 @@ class C {} class D extends C {} -class E implements StackTrace {} +class E extends StackTrace {} void test(void f()) {} main() {} diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline_modelled.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline_modelled.expect index 2db370d3b1e..ab3f6f6f4de 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline_modelled.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.textual_outline_modelled.expect @@ -5,7 +5,7 @@ class C {} class D extends C {} -class E implements StackTrace {} +class E extends StackTrace {} main() {} void test(void f()) {} diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.expect index f035cfe145e..bf9fab61431 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.expect @@ -22,11 +22,12 @@ class D extends self::C { : super self::C::•() ; } -class E extends core::Object implements core::StackTrace { +class E extends core::StackTrace { synthetic constructor •() → self::E* - : super core::Object::•() + : super core::StackTrace::•() ; abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod + abstract member-signature method toString() → core::String*; -> core::StackTrace::toString abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -34,7 +35,6 @@ class E extends core::Object implements core::StackTrace { abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::== abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode - abstract member-signature method toString() → core::String*; -> core::Object::toString abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType } static method test(() →* void f) → void { diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.modular.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.modular.expect index f035cfe145e..bf9fab61431 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.modular.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.modular.expect @@ -22,11 +22,12 @@ class D extends self::C { : super self::C::•() ; } -class E extends core::Object implements core::StackTrace { +class E extends core::StackTrace { synthetic constructor •() → self::E* - : super core::Object::•() + : super core::StackTrace::•() ; abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod + abstract member-signature method toString() → core::String*; -> core::StackTrace::toString abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -34,7 +35,6 @@ class E extends core::Object implements core::StackTrace { abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::== abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode - abstract member-signature method toString() → core::String*; -> core::Object::toString abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType } static method test(() →* void f) → void { diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.outline.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.outline.expect index fb937f03a7c..0bb2c870c34 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.outline.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.outline.expect @@ -20,10 +20,11 @@ class D extends self::C { synthetic constructor •() → self::D* ; } -class E extends core::Object implements core::StackTrace { +class E extends core::StackTrace { synthetic constructor •() → self::E* ; abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod + abstract member-signature method toString() → core::String*; -> core::StackTrace::toString abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -31,7 +32,6 @@ class E extends core::Object implements core::StackTrace { abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::== abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode - abstract member-signature method toString() → core::String*; -> core::Object::toString abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType } static method test(() →* void f) → void diff --git a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.transformed.expect b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.transformed.expect index f035cfe145e..bf9fab61431 100644 --- a/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.transformed.expect +++ b/pkg/front_end/testcases/inference/try_catch_promotion.dart.weak.transformed.expect @@ -22,11 +22,12 @@ class D extends self::C { : super self::C::•() ; } -class E extends core::Object implements core::StackTrace { +class E extends core::StackTrace { synthetic constructor •() → self::E* - : super core::Object::•() + : super core::StackTrace::•() ; abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod + abstract member-signature method toString() → core::String*; -> core::StackTrace::toString abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf @@ -34,7 +35,6 @@ class E extends core::Object implements core::StackTrace { abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::== abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode - abstract member-signature method toString() → core::String*; -> core::Object::toString abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType } static method test(() →* void f) → void { diff --git a/runtime/tests/concurrency/stress_test_list.json b/runtime/tests/concurrency/stress_test_list.json index 670923a026e..2d8369d7ae4 100644 --- a/runtime/tests/concurrency/stress_test_list.json +++ b/runtime/tests/concurrency/stress_test_list.json @@ -2176,6 +2176,7 @@ "../../../tests/language/regress/r24720_test.dart", "../../../tests/language/regress/regress10204_test.dart", "../../../tests/language/regress/regress10321_test.dart", + "../../../tests/language/regress/regress10561_test.dart", "../../../tests/language/regress/regress10581_test.dart", "../../../tests/language/regress/regress10721_test.dart", "../../../tests/language/regress/regress10747_test.dart", @@ -5499,6 +5500,7 @@ "../../../tests/language_2/regress/r24720_test.dart", "../../../tests/language_2/regress/regress10204_test.dart", "../../../tests/language_2/regress/regress10321_test.dart", + "../../../tests/language_2/regress/regress10561_test.dart", "../../../tests/language_2/regress/regress10581_test.dart", "../../../tests/language_2/regress/regress10721_test.dart", "../../../tests/language_2/regress/regress10747_test.dart", diff --git a/runtime/tests/vm/dart/regress_48323_1_test.dart b/runtime/tests/vm/dart/regress_48323_1_test.dart index 65d3c201112..d9c7595ac84 100644 --- a/runtime/tests/vm/dart/regress_48323_1_test.dart +++ b/runtime/tests/vm/dart/regress_48323_1_test.dart @@ -6,7 +6,7 @@ // Verifies that class finalization doesn't crash when seeing // superclass with type arguments which were not finalized yet. -abstract class GraphNode implements Comparable { +abstract class GraphNode extends Comparable { int compareTo(dynamic other) => 0; } diff --git a/samples/ffi/sqlite/lib/src/collections/closable_iterator.dart b/samples/ffi/sqlite/lib/src/collections/closable_iterator.dart index 49abbd2131a..a86a58b2ad5 100644 --- a/samples/ffi/sqlite/lib/src/collections/closable_iterator.dart +++ b/samples/ffi/sqlite/lib/src/collections/closable_iterator.dart @@ -7,7 +7,7 @@ /// [ClosableIterator]s often use resources which should be freed after use. /// The consumer of the iterator can either manually [close] the iterator, or /// consume all elements on which the iterator will automatically be closed. -abstract class ClosableIterator implements Iterator { +abstract class ClosableIterator extends Iterator { /// Close this iterator. void close(); diff --git a/sdk/lib/_internal/wasm/lib/js_helper.dart b/sdk/lib/_internal/wasm/lib/js_helper.dart index 6111d646650..295904cc7e5 100644 --- a/sdk/lib/_internal/wasm/lib/js_helper.dart +++ b/sdk/lib/_internal/wasm/lib/js_helper.dart @@ -100,7 +100,7 @@ extension JSObjectExtension on JSObject { external void operator []=(String key, Object? value); } -class JSArrayIteratorAdapter implements Iterator { +class JSArrayIteratorAdapter extends Iterator { final JSArray array; int index = -1; diff --git a/sdk/lib/collection/splay_tree.dart b/sdk/lib/collection/splay_tree.dart index 55b6402f492..1ab21dbc4d3 100644 --- a/sdk/lib/collection/splay_tree.dart +++ b/sdk/lib/collection/splay_tree.dart @@ -26,8 +26,8 @@ class _SplayTreeSetNode extends _SplayTreeNode> { /// /// A [_SplayTreeNode] that also contains a value, /// and which implements [MapEntry]. -class _SplayTreeMapNode - extends _SplayTreeNode> { +class _SplayTreeMapNode extends _SplayTreeNode> + implements MapEntry { final V value; _SplayTreeMapNode(K key, this.value) : super(key); @@ -35,6 +35,8 @@ class _SplayTreeMapNode _SplayTreeMapNode(key, value) .._left = _left .._right = _right; + + String toString() => "MapEntry($key: $value)"; } /// A splay tree is a self-balancing binary search tree. @@ -834,8 +836,7 @@ class _SplayTreeValueIterator class _SplayTreeMapEntryIterator extends _SplayTreeIterator, MapEntry> { _SplayTreeMapEntryIterator(SplayTreeMap tree) : super(tree); - MapEntry _getValue(_SplayTreeMapNode node) => - MapEntry(node.key, node.value); + MapEntry _getValue(_SplayTreeMapNode node) => node; // Replaces the value of the current node. void _replaceValue(V value) { diff --git a/sdk/lib/convert/string_conversion.dart b/sdk/lib/convert/string_conversion.dart index b0dec898db6..5a310937f20 100644 --- a/sdk/lib/convert/string_conversion.dart +++ b/sdk/lib/convert/string_conversion.dart @@ -53,7 +53,7 @@ abstract class StringConversionSink extends ChunkedConversionSink { /// A [ClosableStringSink] extends the [StringSink] interface by adding a /// `close` method. -abstract class ClosableStringSink implements StringSink { +abstract class ClosableStringSink extends StringSink { /// Creates a new instance combining a [StringSink] [sink] and a callback /// [onClose] which is invoked when the returned instance is closed. factory ClosableStringSink.fromStringSink(StringSink sink, void onClose()) = diff --git a/sdk/lib/core/annotations.dart b/sdk/lib/core/annotations.dart index e437d90bd15..8183375e0f3 100644 --- a/sdk/lib/core/annotations.dart +++ b/sdk/lib/core/annotations.dart @@ -147,7 +147,7 @@ const Object override = _Override(); /// function `foo` is annotated with a pragma 'other-pragma' /// specific to OtherTool. @pragma('vm:entry-point') -final class pragma { +class pragma { /// The name of the hint. /// /// A string that is recognized by one or more tools, or such a string prefixed diff --git a/sdk/lib/core/bigint.dart b/sdk/lib/core/bigint.dart index 28da09dbff4..e5a871c750d 100644 --- a/sdk/lib/core/bigint.dart +++ b/sdk/lib/core/bigint.dart @@ -41,7 +41,7 @@ part of dart.core; /// * [num]: The super class for [int] and [double]. /// * [Numbers](https://dart.dev/guides/language/numbers) in /// [A tour of the Dart language](https://dart.dev/guides/language/language-tour). -abstract final class BigInt implements Comparable { +abstract class BigInt implements Comparable { /// A big integer with the numerical value 0. external static BigInt get zero; diff --git a/sdk/lib/core/comparable.dart b/sdk/lib/core/comparable.dart index 3d0bd51be8f..67df844a0c9 100644 --- a/sdk/lib/core/comparable.dart +++ b/sdk/lib/core/comparable.dart @@ -66,7 +66,7 @@ typedef Comparator = int Function(T a, T b); /// The [DateTime] class has no comparison operators, instead it has the more /// precisely named [DateTime.isBefore] and [DateTime.isAfter], which both /// agree with [DateTime.compareTo]. -abstract interface class Comparable { +abstract class Comparable { /// Compares this object to another object. /// /// Returns a value like a [Comparator] when comparing `this` to [other]. diff --git a/sdk/lib/core/errors.dart b/sdk/lib/core/errors.dart index 368891cae77..d54dcd0400c 100644 --- a/sdk/lib/core/errors.dart +++ b/sdk/lib/core/errors.dart @@ -596,7 +596,7 @@ class ConcurrentModificationError extends Error { } /// Error that the platform can use in case of memory shortage. -final class OutOfMemoryError implements Error { +class OutOfMemoryError implements Error { @pragma("vm:entry-point") const OutOfMemoryError(); String toString() => "Out of Memory"; @@ -605,7 +605,7 @@ final class OutOfMemoryError implements Error { } /// Error that the platform can use in case of stack overflow. -final class StackOverflowError implements Error { +class StackOverflowError implements Error { @pragma("vm:entry-point") const StackOverflowError(); String toString() => "Stack Overflow"; diff --git a/sdk/lib/core/exceptions.dart b/sdk/lib/core/exceptions.dart index c7a064d8ba1..c4c441bc1d8 100644 --- a/sdk/lib/core/exceptions.dart +++ b/sdk/lib/core/exceptions.dart @@ -20,7 +20,7 @@ part of dart.core; /// For failures that are not intended to be caught, use [Error] /// and its subclasses. @pragma('flutter:keep-to-string-in-subtypes') -abstract interface class Exception { +abstract class Exception { factory Exception([var message]) => _Exception(message); } diff --git a/sdk/lib/core/iterator.dart b/sdk/lib/core/iterator.dart index 915e6220bb4..a33e2733113 100644 --- a/sdk/lib/core/iterator.dart +++ b/sdk/lib/core/iterator.dart @@ -31,7 +31,7 @@ part of dart.core; /// **See also:** /// [Iteration](https://dart.dev/guides/libraries/library-tour#iteration) /// in the [library tour](https://dart.dev/guides/libraries/library-tour) -abstract interface class Iterator { +abstract class Iterator { /// Advances the iterator to the next element of the iteration. /// /// Should be called before reading [current]. diff --git a/sdk/lib/core/map.dart b/sdk/lib/core/map.dart index aa8646719af..ea609e03905 100644 --- a/sdk/lib/core/map.dart +++ b/sdk/lib/core/map.dart @@ -468,7 +468,9 @@ abstract class Map { /// the `MapEntry` class will be changed to such a type, /// and will likely no longer be able to be implemented or extended /// by classes. -final class MapEntry { +// TODO(lrn): Make this class `final` when class modifiers are introduced. +// Change to an `inline class` when those are available. +class MapEntry { /// The key of the entry. /// /// ```dart diff --git a/sdk/lib/core/pattern.dart b/sdk/lib/core/pattern.dart index 9f6e34debdc..fbf70ea1b4c 100644 --- a/sdk/lib/core/pattern.dart +++ b/sdk/lib/core/pattern.dart @@ -5,7 +5,7 @@ part of dart.core; /// An interface for basic searches within strings. -abstract interface class Pattern { +abstract class Pattern { /// Matches this pattern against the string repeatedly. /// /// If [start] is provided, matching will start at that index. @@ -82,7 +82,7 @@ abstract interface class Pattern { /// that were part of the matching. These are called _groups_ in the `Match` /// object. Some patterns may never have any groups, and their matches always /// have zero [groupCount]. -abstract interface class Match { +abstract class Match { /// The index in the string where the match starts. int get start; diff --git a/sdk/lib/core/regexp.dart b/sdk/lib/core/regexp.dart index 921af06189c..9ca82395f8e 100644 --- a/sdk/lib/core/regexp.dart +++ b/sdk/lib/core/regexp.dart @@ -213,7 +213,7 @@ part of dart.core; /// when the regexp does not find a match. /// Several guides to [improving the performance of regular expressions](https://www.google.com/search?q=performance+of+regular+expressions) /// exist on the internet. Use these as inspirations, too. -abstract interface class RegExp implements Pattern { +abstract class RegExp implements Pattern { /// Constructs a regular expression. /// /// Throws a [FormatException] if [source] does not follow valid regular @@ -469,7 +469,7 @@ abstract interface class RegExp implements Pattern { /// } /// ``` @Since("2.3") -abstract interface class RegExpMatch implements Match { +abstract class RegExpMatch implements Match { /// The string captured by the named capture group [name]. /// /// Returns the substring of the input that the diff --git a/sdk/lib/core/stacktrace.dart b/sdk/lib/core/stacktrace.dart index 24c8ea23abe..dbba199885d 100644 --- a/sdk/lib/core/stacktrace.dart +++ b/sdk/lib/core/stacktrace.dart @@ -11,7 +11,7 @@ part of dart.core; /// /// These objects are created by the runtime, it is not possible to create /// them programmatically. -abstract interface class StackTrace { +abstract class StackTrace { /// A stack trace object with no information. /// /// This stack trace is used as the default in situations where diff --git a/sdk/lib/core/string_sink.dart b/sdk/lib/core/string_sink.dart index 35013a47002..565ce563255 100644 --- a/sdk/lib/core/string_sink.dart +++ b/sdk/lib/core/string_sink.dart @@ -4,7 +4,7 @@ part of dart.core; -abstract interface class StringSink { +abstract class StringSink { /// Writes the string representation of [object]. /// /// Converts [object] to a string using `object.toString()`. diff --git a/sdk/lib/core/weak.dart b/sdk/lib/core/weak.dart index 0c74cd92820..0ae32c7013d 100644 --- a/sdk/lib/core/weak.dart +++ b/sdk/lib/core/weak.dart @@ -30,7 +30,7 @@ part of dart.core; /// There is no restriction on other classes, even for compile time constant /// objects. Be careful if adding expando properties to compile time constants, /// since they will stay alive forever. -final class Expando { +class Expando { /// The name of the this [Expando] as passed to the constructor. /// /// If no name was passed to the constructor, the value is the `null` value. @@ -123,7 +123,7 @@ final class Expando { /// } /// ``` @Since("2.17") -abstract final class WeakReference { +abstract class WeakReference { /// Creates a [WeakReference] pointing to the given [target]. /// /// The [target] must be an object supported as an [Expando] key, @@ -220,7 +220,7 @@ abstract final class WeakReference { /// function rather than a Dart function, use `dart:ffi`'s [NativeFinalizer] /// instead. @Since("2.17") -abstract final class Finalizer { +abstract class Finalizer { /// Creates a finalizer with the given finalization callback. /// /// The [callback] is bound to the current zone diff --git a/sdk/lib/internal/iterable.dart b/sdk/lib/internal/iterable.dart index 15f9f6cfa62..4dbd20a9039 100644 --- a/sdk/lib/internal/iterable.dart +++ b/sdk/lib/internal/iterable.dart @@ -381,7 +381,7 @@ class EfficientLengthMappedIterable extends MappedIterable : super._(iterable, function); } -class MappedIterator implements Iterator { +class MappedIterator extends Iterator { T? _current; final Iterator _iterator; final _Transformation _f; @@ -430,7 +430,7 @@ class WhereIterable extends Iterable { MappedIterable._(this, toElement); } -class WhereIterator implements Iterator { +class WhereIterator extends Iterator { final Iterator _iterator; final _ElementPredicate _f; @@ -522,7 +522,7 @@ class EfficientLengthTakeIterable extends TakeIterable } } -class TakeIterator implements Iterator { +class TakeIterator extends Iterator { final Iterator _iterator; int _remaining; @@ -560,7 +560,7 @@ class TakeWhileIterable extends Iterable { } } -class TakeWhileIterator implements Iterator { +class TakeWhileIterator extends Iterator { final Iterator _iterator; final _ElementPredicate _f; bool _isFinished = false; @@ -631,7 +631,7 @@ int _checkCount(int count) { return count; } -class SkipIterator implements Iterator { +class SkipIterator extends Iterator { final Iterator _iterator; int _skipCount; @@ -659,7 +659,7 @@ class SkipWhileIterable extends Iterable { } } -class SkipWhileIterator implements Iterator { +class SkipWhileIterator extends Iterator { final Iterator _iterator; final _ElementPredicate _f; bool _hasSkipped = false; diff --git a/tests/language/regress/regress10561_test.dart b/tests/language/regress/regress10561_test.dart new file mode 100644 index 00000000000..16e0cca67f5 --- /dev/null +++ b/tests/language/regress/regress10561_test.dart @@ -0,0 +1,16 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Regression test for dart2js that used to miscompile classes +// extending HashMap, because HashMap is patched. + +import "package:expect/expect.dart"; + +import 'dart:collection'; + +class Foo extends Expando {} + +main() { + Expect.isNull(new Foo()[new Object()]); +} diff --git a/tests/language/regress/regress9949_test.dart b/tests/language/regress/regress9949_test.dart index 3bd0f9a79f6..38ff6edb07e 100644 --- a/tests/language/regress/regress9949_test.dart +++ b/tests/language/regress/regress9949_test.dart @@ -8,11 +8,11 @@ import "package:expect/expect.dart"; import 'dart:collection'; -class Crash extends StringBuffer { +class Crash extends Expando { Crash() : super(); } void main() { Crash expando = new Crash(); - Expect.isTrue(expando is StringBuffer); + Expect.isTrue(expando is Expando); } diff --git a/tests/language_2/regress/regress10561_test.dart b/tests/language_2/regress/regress10561_test.dart new file mode 100644 index 00000000000..0961a2e7f7e --- /dev/null +++ b/tests/language_2/regress/regress10561_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// @dart = 2.9 + +// Regression test for dart2js that used to miscompile classes +// extending HashMap, because HashMap is patched. + +import "package:expect/expect.dart"; + +import 'dart:collection'; + +class Foo extends Expando {} + +main() { + Expect.isNull(new Foo()[new Object()]); +} diff --git a/tests/language_2/regress/regress9949_test.dart b/tests/language_2/regress/regress9949_test.dart index b3d50c45ca6..0054039ee3e 100644 --- a/tests/language_2/regress/regress9949_test.dart +++ b/tests/language_2/regress/regress9949_test.dart @@ -10,11 +10,11 @@ import "package:expect/expect.dart"; import 'dart:collection'; -class Crash extends StringBuffer { +class Crash extends Expando { Crash() : super(); } void main() { Crash expando = new Crash(); - Expect.isTrue(expando is StringBuffer); + Expect.isTrue(expando is Expando); }