mirror of
https://github.com/dart-lang/sdk
synced 2024-10-04 16:04:53 +00:00
Add more interface
and final
modifiers to dart:core
.
Make intent explicit for classes which are intended as interfaces, or which are not intended to be subclassed. Mainly classes which are pure interfaces are marked as such, and platform-specific classes not intended for subclassing are made `final`. The `final` classes includes `BigInt`, which is written to assume that arguments inherit its private members (it runs `_ensureSystemBigInt` on arguments). It also includes the `Expando`, `WeakReference` and `Finalizer` classes, which are just intended as stand-alone implementation classes for accessing platform-specific functionality. Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180 Reviewed-by: Stephen Adams <sra@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com> Reviewed-by: Aske Simon Christensen <askesc@google.com> Reviewed-by: Nate Bosch <nbosch@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
This commit is contained in:
parent
615e44821a
commit
4f8333e80e
31
CHANGELOG.md
31
CHANGELOG.md
|
@ -61,13 +61,36 @@
|
|||
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 it is migrated
|
||||
Some changes to platform libraries only affect code when that code is migrated
|
||||
to language version 3.0.
|
||||
- The `Function` type can no longer be implemented.
|
||||
- The `Function` type can no longer be implemented, extended or mixed in.
|
||||
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 implemented
|
||||
by class-modifier aware code.
|
||||
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.
|
||||
|
||||
[#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
|
||||
|
|
|
@ -31,7 +31,7 @@ class LinkIterator<T> implements Iterator<T> {
|
|||
|
||||
typedef T Transformation<S, T>(S input);
|
||||
|
||||
class MappedLinkIterator<S, T> extends Iterator<T> {
|
||||
class MappedLinkIterator<S, T> implements Iterator<T> {
|
||||
Transformation<S, T> _transformation;
|
||||
Link<S> _link;
|
||||
T? _current;
|
||||
|
|
|
@ -967,7 +967,7 @@ class SubtypesIterable extends IterableBase<ClassEntity> {
|
|||
}
|
||||
|
||||
/// Iterator for the subtypes in a [ClassSet].
|
||||
class SubtypesIterator extends Iterator<ClassEntity> {
|
||||
class SubtypesIterator implements Iterator<ClassEntity> {
|
||||
final SubtypesIterable iterable;
|
||||
Iterator<ClassEntity>? elements;
|
||||
Iterator<ClassHierarchyNode>? hierarchyNodes;
|
||||
|
|
|
@ -13,19 +13,19 @@ import '../helpers/element_lookup.dart';
|
|||
import 'package:compiler/src/util/memory_compiler.dart';
|
||||
|
||||
const String CODE = """
|
||||
class A extends Comparable {
|
||||
class A implements Comparable {
|
||||
int compareTo(x) { return 0; }
|
||||
}
|
||||
class B extends Comparable {
|
||||
class B implements Comparable {
|
||||
int compareTo(x) { return 0; }
|
||||
}
|
||||
class C extends Comparable {
|
||||
class C implements Comparable {
|
||||
int compareTo(x) { return 0; }
|
||||
}
|
||||
class D extends Comparable {
|
||||
class D implements Comparable {
|
||||
int compareTo(x) { return 0; }
|
||||
}
|
||||
class E extends Comparable {
|
||||
class E implements Comparable {
|
||||
int compareTo(x) { return 0; }
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ worlds:
|
|||
- entry: main.dart
|
||||
sources:
|
||||
main.dart: |
|
||||
abstract class AIterator extends Iterator {
|
||||
abstract class AIterator implements Iterator {
|
||||
}
|
||||
class Foo {
|
||||
final a;
|
||||
|
@ -25,7 +25,7 @@ worlds:
|
|||
errors: true
|
||||
sources:
|
||||
main.dart: |
|
||||
abstract class BIterator extends Iterator {
|
||||
abstract class BIterator implements Iterator {
|
||||
}
|
||||
class Foo {
|
||||
final a kjsdf ksjdf ;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
main = main::main;
|
||||
library from "org-dartlang-test:///main.dart" as main {
|
||||
|
||||
abstract class AIterator extends dart.core::Iterator<dynamic> {
|
||||
abstract class AIterator extends dart.core::Object implements dart.core::Iterator<dynamic> {
|
||||
synthetic constructor •() → main::AIterator
|
||||
: super dart.core::Iterator::•()
|
||||
: super dart.core::Object::•()
|
||||
;
|
||||
}
|
||||
class Foo extends dart.core::Object {
|
||||
|
|
|
@ -30,9 +30,9 @@ library from "org-dartlang-test:///main.dart" as main {
|
|||
// ^
|
||||
//
|
||||
|
||||
abstract class BIterator extends dart.core::Iterator<dynamic> {
|
||||
abstract class BIterator extends dart.core::Object implements dart.core::Iterator<dynamic> {
|
||||
synthetic constructor •() → main::BIterator
|
||||
: super dart.core::Iterator::•()
|
||||
: super dart.core::Object::•()
|
||||
;
|
||||
}
|
||||
class Foo extends dart.core::Object {
|
||||
|
|
|
@ -11,7 +11,7 @@ class C {}
|
|||
|
||||
class D extends C {}
|
||||
|
||||
class E extends StackTrace {}
|
||||
class E implements StackTrace {}
|
||||
|
||||
void test(void f()) {
|
||||
try {
|
||||
|
|
|
@ -29,12 +29,11 @@ class D extends self::C {
|
|||
: super self::C::•()
|
||||
;
|
||||
}
|
||||
class E extends core::StackTrace {
|
||||
class E extends core::Object implements core::StackTrace {
|
||||
synthetic constructor •() → self::E*
|
||||
: super core::StackTrace::•()
|
||||
: super core::Object::•()
|
||||
;
|
||||
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
|
||||
|
@ -42,6 +41,7 @@ class E extends 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 {
|
||||
|
|
|
@ -29,12 +29,11 @@ class D extends self::C {
|
|||
: super self::C::•()
|
||||
;
|
||||
}
|
||||
class E extends core::StackTrace {
|
||||
class E extends core::Object implements core::StackTrace {
|
||||
synthetic constructor •() → self::E*
|
||||
: super core::StackTrace::•()
|
||||
: super core::Object::•()
|
||||
;
|
||||
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
|
||||
|
@ -42,6 +41,7 @@ class E extends 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 {
|
||||
|
|
|
@ -5,7 +5,7 @@ class C {}
|
|||
|
||||
class D extends C {}
|
||||
|
||||
class E extends StackTrace {}
|
||||
class E implements StackTrace {}
|
||||
|
||||
void test(void f()) {}
|
||||
main() {}
|
||||
|
|
|
@ -5,7 +5,7 @@ class C {}
|
|||
|
||||
class D extends C {}
|
||||
|
||||
class E extends StackTrace {}
|
||||
class E implements StackTrace {}
|
||||
|
||||
main() {}
|
||||
void test(void f()) {}
|
||||
|
|
|
@ -22,12 +22,11 @@ class D extends self::C {
|
|||
: super self::C::•()
|
||||
;
|
||||
}
|
||||
class E extends core::StackTrace {
|
||||
class E extends core::Object implements core::StackTrace {
|
||||
synthetic constructor •() → self::E*
|
||||
: super core::StackTrace::•()
|
||||
: super core::Object::•()
|
||||
;
|
||||
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
|
||||
|
@ -35,6 +34,7 @@ class E extends 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 {
|
||||
|
|
|
@ -22,12 +22,11 @@ class D extends self::C {
|
|||
: super self::C::•()
|
||||
;
|
||||
}
|
||||
class E extends core::StackTrace {
|
||||
class E extends core::Object implements core::StackTrace {
|
||||
synthetic constructor •() → self::E*
|
||||
: super core::StackTrace::•()
|
||||
: super core::Object::•()
|
||||
;
|
||||
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
|
||||
|
@ -35,6 +34,7 @@ class E extends 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 {
|
||||
|
|
|
@ -20,11 +20,10 @@ class D extends self::C {
|
|||
synthetic constructor •() → self::D*
|
||||
;
|
||||
}
|
||||
class E extends core::StackTrace {
|
||||
class E extends core::Object implements 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
|
||||
|
@ -32,6 +31,7 @@ class E extends 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
|
||||
|
|
|
@ -22,12 +22,11 @@ class D extends self::C {
|
|||
: super self::C::•()
|
||||
;
|
||||
}
|
||||
class E extends core::StackTrace {
|
||||
class E extends core::Object implements core::StackTrace {
|
||||
synthetic constructor •() → self::E*
|
||||
: super core::StackTrace::•()
|
||||
: super core::Object::•()
|
||||
;
|
||||
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
|
||||
|
@ -35,6 +34,7 @@ class E extends 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 {
|
||||
|
|
|
@ -2176,7 +2176,6 @@
|
|||
"../../../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",
|
||||
|
@ -5500,7 +5499,6 @@
|
|||
"../../../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",
|
||||
|
|
|
@ -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 extends Comparable<dynamic> {
|
||||
abstract class GraphNode implements Comparable<dynamic> {
|
||||
int compareTo(dynamic other) => 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<T> extends Iterator<T> {
|
||||
abstract class ClosableIterator<T> implements Iterator<T> {
|
||||
/// Close this iterator.
|
||||
void close();
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ extension JSObjectExtension on JSObject {
|
|||
external void operator []=(String key, Object? value);
|
||||
}
|
||||
|
||||
class JSArrayIteratorAdapter<T> extends Iterator<T> {
|
||||
class JSArrayIteratorAdapter<T> implements Iterator<T> {
|
||||
final JSArray array;
|
||||
int index = -1;
|
||||
|
||||
|
|
|
@ -26,8 +26,8 @@ class _SplayTreeSetNode<K> extends _SplayTreeNode<K, _SplayTreeSetNode<K>> {
|
|||
///
|
||||
/// A [_SplayTreeNode] that also contains a value,
|
||||
/// and which implements [MapEntry].
|
||||
class _SplayTreeMapNode<K, V> extends _SplayTreeNode<K, _SplayTreeMapNode<K, V>>
|
||||
implements MapEntry<K, V> {
|
||||
class _SplayTreeMapNode<K, V>
|
||||
extends _SplayTreeNode<K, _SplayTreeMapNode<K, V>> {
|
||||
final V value;
|
||||
_SplayTreeMapNode(K key, this.value) : super(key);
|
||||
|
||||
|
@ -35,8 +35,6 @@ class _SplayTreeMapNode<K, V> extends _SplayTreeNode<K, _SplayTreeMapNode<K, V>>
|
|||
_SplayTreeMapNode<K, V>(key, value)
|
||||
.._left = _left
|
||||
.._right = _right;
|
||||
|
||||
String toString() => "MapEntry($key: $value)";
|
||||
}
|
||||
|
||||
/// A splay tree is a self-balancing binary search tree.
|
||||
|
@ -836,7 +834,8 @@ class _SplayTreeValueIterator<K, V>
|
|||
class _SplayTreeMapEntryIterator<K, V>
|
||||
extends _SplayTreeIterator<K, _SplayTreeMapNode<K, V>, MapEntry<K, V>> {
|
||||
_SplayTreeMapEntryIterator(SplayTreeMap<K, V> tree) : super(tree);
|
||||
MapEntry<K, V> _getValue(_SplayTreeMapNode<K, V> node) => node;
|
||||
MapEntry<K, V> _getValue(_SplayTreeMapNode<K, V> node) =>
|
||||
MapEntry<K, V>(node.key, node.value);
|
||||
|
||||
// Replaces the value of the current node.
|
||||
void _replaceValue(V value) {
|
||||
|
|
|
@ -53,7 +53,7 @@ abstract class StringConversionSink extends ChunkedConversionSink<String> {
|
|||
|
||||
/// A [ClosableStringSink] extends the [StringSink] interface by adding a
|
||||
/// `close` method.
|
||||
abstract class ClosableStringSink extends StringSink {
|
||||
abstract class ClosableStringSink implements 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()) =
|
||||
|
|
|
@ -147,7 +147,7 @@ const Object override = _Override();
|
|||
/// function `foo` is annotated with a pragma 'other-pragma'
|
||||
/// specific to OtherTool.
|
||||
@pragma('vm:entry-point')
|
||||
class pragma {
|
||||
final class pragma {
|
||||
/// The name of the hint.
|
||||
///
|
||||
/// A string that is recognized by one or more tools, or such a string prefixed
|
||||
|
|
|
@ -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 class BigInt implements Comparable<BigInt> {
|
||||
abstract final class BigInt implements Comparable<BigInt> {
|
||||
/// A big integer with the numerical value 0.
|
||||
external static BigInt get zero;
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ typedef Comparator<T> = 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 class Comparable<T> {
|
||||
abstract interface class Comparable<T> {
|
||||
/// Compares this object to another object.
|
||||
///
|
||||
/// Returns a value like a [Comparator] when comparing `this` to [other].
|
||||
|
|
|
@ -596,7 +596,7 @@ class ConcurrentModificationError extends Error {
|
|||
}
|
||||
|
||||
/// Error that the platform can use in case of memory shortage.
|
||||
class OutOfMemoryError implements Error {
|
||||
final class OutOfMemoryError implements Error {
|
||||
@pragma("vm:entry-point")
|
||||
const OutOfMemoryError();
|
||||
String toString() => "Out of Memory";
|
||||
|
@ -605,7 +605,7 @@ class OutOfMemoryError implements Error {
|
|||
}
|
||||
|
||||
/// Error that the platform can use in case of stack overflow.
|
||||
class StackOverflowError implements Error {
|
||||
final class StackOverflowError implements Error {
|
||||
@pragma("vm:entry-point")
|
||||
const StackOverflowError();
|
||||
String toString() => "Stack Overflow";
|
||||
|
|
|
@ -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 class Exception {
|
||||
abstract interface class Exception {
|
||||
factory Exception([var message]) => _Exception(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 class Iterator<E> {
|
||||
abstract interface class Iterator<E> {
|
||||
/// Advances the iterator to the next element of the iteration.
|
||||
///
|
||||
/// Should be called before reading [current].
|
||||
|
|
|
@ -468,9 +468,7 @@ abstract class Map<K, V> {
|
|||
/// the `MapEntry` class will be changed to such a type,
|
||||
/// and will likely no longer be able to be implemented or extended
|
||||
/// by classes.
|
||||
// TODO(lrn): Make this class `final` when class modifiers are introduced.
|
||||
// Change to an `inline class` when those are available.
|
||||
class MapEntry<K, V> {
|
||||
final class MapEntry<K, V> {
|
||||
/// The key of the entry.
|
||||
///
|
||||
/// ```dart
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
part of dart.core;
|
||||
|
||||
/// An interface for basic searches within strings.
|
||||
abstract class Pattern {
|
||||
abstract interface class Pattern {
|
||||
/// Matches this pattern against the string repeatedly.
|
||||
///
|
||||
/// If [start] is provided, matching will start at that index.
|
||||
|
@ -82,7 +82,7 @@ abstract 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 class Match {
|
||||
abstract interface class Match {
|
||||
/// The index in the string where the match starts.
|
||||
int get start;
|
||||
|
||||
|
|
|
@ -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 class RegExp implements Pattern {
|
||||
abstract interface class RegExp implements Pattern {
|
||||
/// Constructs a regular expression.
|
||||
///
|
||||
/// Throws a [FormatException] if [source] does not follow valid regular
|
||||
|
@ -469,7 +469,7 @@ abstract class RegExp implements Pattern {
|
|||
/// }
|
||||
/// ```
|
||||
@Since("2.3")
|
||||
abstract class RegExpMatch implements Match {
|
||||
abstract interface class RegExpMatch implements Match {
|
||||
/// The string captured by the named capture group [name].
|
||||
///
|
||||
/// Returns the substring of the input that the
|
||||
|
|
|
@ -11,7 +11,7 @@ part of dart.core;
|
|||
///
|
||||
/// These objects are created by the runtime, it is not possible to create
|
||||
/// them programmatically.
|
||||
abstract class StackTrace {
|
||||
abstract interface class StackTrace {
|
||||
/// A stack trace object with no information.
|
||||
///
|
||||
/// This stack trace is used as the default in situations where
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
part of dart.core;
|
||||
|
||||
abstract class StringSink {
|
||||
abstract interface class StringSink {
|
||||
/// Writes the string representation of [object].
|
||||
///
|
||||
/// Converts [object] to a string using `object.toString()`.
|
||||
|
|
|
@ -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.
|
||||
class Expando<T extends Object> {
|
||||
final class Expando<T extends Object> {
|
||||
/// 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 @@ class Expando<T extends Object> {
|
|||
/// }
|
||||
/// ```
|
||||
@Since("2.17")
|
||||
abstract class WeakReference<T extends Object> {
|
||||
abstract final class WeakReference<T extends Object> {
|
||||
/// Creates a [WeakReference] pointing to the given [target].
|
||||
///
|
||||
/// The [target] must be an object supported as an [Expando] key,
|
||||
|
@ -220,7 +220,7 @@ abstract class WeakReference<T extends Object> {
|
|||
/// function rather than a Dart function, use `dart:ffi`'s [NativeFinalizer]
|
||||
/// instead.
|
||||
@Since("2.17")
|
||||
abstract class Finalizer<T> {
|
||||
abstract final class Finalizer<T> {
|
||||
/// Creates a finalizer with the given finalization callback.
|
||||
///
|
||||
/// The [callback] is bound to the current zone
|
||||
|
|
|
@ -381,7 +381,7 @@ class EfficientLengthMappedIterable<S, T> extends MappedIterable<S, T>
|
|||
: super._(iterable, function);
|
||||
}
|
||||
|
||||
class MappedIterator<S, T> extends Iterator<T> {
|
||||
class MappedIterator<S, T> implements Iterator<T> {
|
||||
T? _current;
|
||||
final Iterator<S> _iterator;
|
||||
final _Transformation<S, T> _f;
|
||||
|
@ -430,7 +430,7 @@ class WhereIterable<E> extends Iterable<E> {
|
|||
MappedIterable<E, T>._(this, toElement);
|
||||
}
|
||||
|
||||
class WhereIterator<E> extends Iterator<E> {
|
||||
class WhereIterator<E> implements Iterator<E> {
|
||||
final Iterator<E> _iterator;
|
||||
final _ElementPredicate<E> _f;
|
||||
|
||||
|
@ -522,7 +522,7 @@ class EfficientLengthTakeIterable<E> extends TakeIterable<E>
|
|||
}
|
||||
}
|
||||
|
||||
class TakeIterator<E> extends Iterator<E> {
|
||||
class TakeIterator<E> implements Iterator<E> {
|
||||
final Iterator<E> _iterator;
|
||||
int _remaining;
|
||||
|
||||
|
@ -560,7 +560,7 @@ class TakeWhileIterable<E> extends Iterable<E> {
|
|||
}
|
||||
}
|
||||
|
||||
class TakeWhileIterator<E> extends Iterator<E> {
|
||||
class TakeWhileIterator<E> implements Iterator<E> {
|
||||
final Iterator<E> _iterator;
|
||||
final _ElementPredicate<E> _f;
|
||||
bool _isFinished = false;
|
||||
|
@ -631,7 +631,7 @@ int _checkCount(int count) {
|
|||
return count;
|
||||
}
|
||||
|
||||
class SkipIterator<E> extends Iterator<E> {
|
||||
class SkipIterator<E> implements Iterator<E> {
|
||||
final Iterator<E> _iterator;
|
||||
int _skipCount;
|
||||
|
||||
|
@ -659,7 +659,7 @@ class SkipWhileIterable<E> extends Iterable<E> {
|
|||
}
|
||||
}
|
||||
|
||||
class SkipWhileIterator<E> extends Iterator<E> {
|
||||
class SkipWhileIterator<E> implements Iterator<E> {
|
||||
final Iterator<E> _iterator;
|
||||
final _ElementPredicate<E> _f;
|
||||
bool _hasSkipped = false;
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
// 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()]);
|
||||
}
|
|
@ -8,11 +8,11 @@
|
|||
import "package:expect/expect.dart";
|
||||
import 'dart:collection';
|
||||
|
||||
class Crash extends Expando<String> {
|
||||
class Crash extends StringBuffer {
|
||||
Crash() : super();
|
||||
}
|
||||
|
||||
void main() {
|
||||
Crash expando = new Crash();
|
||||
Expect.isTrue(expando is Expando);
|
||||
Expect.isTrue(expando is StringBuffer);
|
||||
}
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
// 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()]);
|
||||
}
|
|
@ -10,11 +10,11 @@
|
|||
import "package:expect/expect.dart";
|
||||
import 'dart:collection';
|
||||
|
||||
class Crash extends Expando<String> {
|
||||
class Crash extends StringBuffer {
|
||||
Crash() : super();
|
||||
}
|
||||
|
||||
void main() {
|
||||
Crash expando = new Crash();
|
||||
Expect.isTrue(expando is Expando);
|
||||
Expect.isTrue(expando is StringBuffer);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue