Document which classes in dart:typed_data cannot be extended or implemented.
Cf. pkg/front_end/lib/src/fasta/denylisted_classes.dart.
Change-Id: Ib2692e763506164a34eca89ab98adc087642dce8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252003
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
diff --git a/sdk/lib/typed_data/typed_data.dart b/sdk/lib/typed_data/typed_data.dart
index ea6a330..7dce112 100644
--- a/sdk/lib/typed_data/typed_data.dart
+++ b/sdk/lib/typed_data/typed_data.dart
@@ -24,6 +24,9 @@
///
/// Used to process large quantities of binary or numerical data
/// more efficiently using a typed view.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// ByteBuffer.
abstract class ByteBuffer {
/// Returns the length of this byte buffer, in bytes.
int get lengthInBytes;
@@ -340,6 +343,9 @@
}
/// A typed view of a sequence of bytes.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// TypedData.
abstract class TypedData {
/// Returns the number of bytes in the representation of each element in this
/// list.
@@ -377,6 +383,9 @@
/// Describes endianness to be used when accessing or updating a
/// sequence of bytes.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Endian.
class Endian {
final bool _littleEndian;
const Endian._(this._littleEndian);
@@ -421,6 +430,9 @@
/// bdata.setFloat32(0, 3.04);
/// int huh = bdata.getInt32(0); // 0x40428f5c
/// ```
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// ByteData.
abstract class ByteData implements TypedData {
/// Creates a [ByteData] of the specified length (in elements), all of
/// whose bytes are initially zero.
@@ -704,6 +716,9 @@
/// Integers stored in the list are truncated to their low eight bits,
/// interpreted as a signed 8-bit two's complement integer with values in the
/// range -128 to +127.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Int8List.
abstract class Int8List implements List<int>, _TypedIntList {
/// Creates an [Int8List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -814,6 +829,9 @@
/// Integers stored in the list are truncated to their low eight bits,
/// interpreted as an unsigned 8-bit integer with values in the
/// range 0 to 255.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Uint8List.
abstract class Uint8List implements List<int>, _TypedIntList {
/// Creates a [Uint8List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -931,6 +949,9 @@
/// Integers stored in the list are clamped to an unsigned eight bit value.
/// That is, all values below zero are stored as zero
/// and all values above 255 are stored as 255.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Uint8ClampedList.
abstract class Uint8ClampedList implements List<int>, _TypedIntList {
/// Creates a [Uint8ClampedList] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -1044,6 +1065,9 @@
/// Integers stored in the list are truncated to their low 16 bits,
/// interpreted as a signed 16-bit two's complement integer with values in the
/// range -32768 to +32767.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Int16List.
abstract class Int16List implements List<int>, _TypedIntList {
/// Creates an [Int16List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -1166,6 +1190,9 @@
/// Integers stored in the list are truncated to their low 16 bits,
/// interpreted as an unsigned 16-bit integer with values in the
/// range 0 to 65535.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Uint16List.
abstract class Uint16List implements List<int>, _TypedIntList {
/// Creates a [Uint16List] of the specified length (in elements), all
/// of whose elements are initially zero.
@@ -1289,6 +1316,9 @@
/// Integers stored in the list are truncated to their low 32 bits,
/// interpreted as a signed 32-bit two's complement integer with values in the
/// range -2147483648 to 2147483647.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Int32List.
abstract class Int32List implements List<int>, _TypedIntList {
/// Creates an [Int32List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -1411,6 +1441,9 @@
/// Integers stored in the list are truncated to their low 32 bits,
/// interpreted as an unsigned 32-bit integer with values in the
/// range 0 to 4294967295.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Uint32List.
abstract class Uint32List implements List<int>, _TypedIntList {
/// Creates a [Uint32List] of the specified length (in elements), all
/// of whose elements are initially zero.
@@ -1534,6 +1567,9 @@
/// Integers stored in the list are truncated to their low 64 bits,
/// interpreted as a signed 64-bit two's complement integer with values in the
/// range -9223372036854775808 to +9223372036854775807.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Int64List.
abstract class Int64List implements List<int>, _TypedIntList {
/// Creates an [Int64List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -1656,6 +1692,9 @@
/// Integers stored in the list are truncated to their low 64 bits,
/// interpreted as an unsigned 64-bit integer with values in the
/// range 0 to 18446744073709551615.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Uint64List.
abstract class Uint64List implements List<int>, _TypedIntList {
/// Creates a [Uint64List] of the specified length (in elements), all
/// of whose elements are initially zero.
@@ -1780,6 +1819,9 @@
/// Double values stored in the list are converted to the nearest
/// single-precision value. Values read are converted to a double
/// value with the same value.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Float32List.
abstract class Float32List implements List<double>, _TypedFloatList {
/// Creates a [Float32List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -1899,6 +1941,9 @@
/// For long lists, this
/// implementation can be considerably more space- and time-efficient than
/// the default [List] implementation.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Float64List.
abstract class Float64List implements List<double>, _TypedFloatList {
/// Creates a [Float64List] of the specified length (in elements), all of
/// whose elements are initially zero.
@@ -2014,6 +2059,9 @@
///
/// For long lists, this implementation will be considerably more
/// space- and time-efficient than the default [List] implementation.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Float32x4List.
abstract class Float32x4List implements List<Float32x4>, TypedData {
/// Creates a [Float32x4List] of the specified length (in elements),
/// all of whose elements are initially zero.
@@ -2256,6 +2304,9 @@
///
/// For long lists, this implementation will be considerably more
/// space- and time-efficient than the default [List] implementation.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Float64x2List.
abstract class Float64x2List implements List<Float64x2>, TypedData {
/// Creates a [Float64x2List] of the specified length (in elements),
/// all of whose elements have all lanes set to zero.
@@ -2376,6 +2427,9 @@
///
/// Float32x4 stores 4 32-bit floating point values in "lanes".
/// The lanes are "x", "y", "z", and "w" respectively.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Float32x4.
abstract class Float32x4 {
external factory Float32x4(double x, double y, double z, double w);
external factory Float32x4.splat(double v);
@@ -3097,6 +3151,9 @@
///
/// Float64x2 stores 2 64-bit floating point values in "lanes".
/// The lanes are "x" and "y" respectively.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// Float64x2.
abstract class Float64x2 {
external factory Float64x2(double x, double y);
external factory Float64x2.splat(double v);
diff --git a/sdk/lib/typed_data/unmodifiable_typed_data.dart b/sdk/lib/typed_data/unmodifiable_typed_data.dart
index 43aaa84..4647798 100644
--- a/sdk/lib/typed_data/unmodifiable_typed_data.dart
+++ b/sdk/lib/typed_data/unmodifiable_typed_data.dart
@@ -5,6 +5,9 @@
part of dart.typed_data;
/// A read-only view of a [ByteBuffer].
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableByteBufferView.
class UnmodifiableByteBufferView implements ByteBuffer {
final ByteBuffer _data;
@@ -65,6 +68,9 @@
}
/// A read-only view of a [ByteData].
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableByteDataView.
class UnmodifiableByteDataView implements ByteData {
final ByteData _data;
@@ -170,6 +176,9 @@
}
/// View of a [Uint8List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableUint8ListView.
class UnmodifiableUint8ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Uint8List, Uint8List>
implements Uint8List {
@@ -180,6 +189,9 @@
}
/// View of a [Int8List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableInt8ListView.
class UnmodifiableInt8ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Int8List, Int8List>
implements Int8List {
@@ -190,6 +202,9 @@
}
/// View of a [Uint8ClampedList] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableUint8ClampedListView.
class UnmodifiableUint8ClampedListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Uint8ClampedList, Uint8ClampedList>
implements Uint8ClampedList {
@@ -200,6 +215,9 @@
}
/// View of a [Uint16List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableUint16ListView.
class UnmodifiableUint16ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Uint16List, Uint16List>
implements Uint16List {
@@ -210,6 +228,9 @@
}
/// View of a [Int16List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableInt16ListView.
class UnmodifiableInt16ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Int16List, Int16List>
implements Int16List {
@@ -220,6 +241,9 @@
}
/// View of a [Uint32List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableUint32ListView.
class UnmodifiableUint32ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Uint32List, Uint32List>
implements Uint32List {
@@ -230,6 +254,9 @@
}
/// View of a [Int32List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableInt32ListView.
class UnmodifiableInt32ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Int32List, Int32List>
implements Int32List {
@@ -240,6 +267,9 @@
}
/// View of a [Uint64List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableUint64ListView.
class UnmodifiableUint64ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Uint64List, Uint64List>
implements Uint64List {
@@ -250,6 +280,9 @@
}
/// View of a [Int64List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableInt64ListView.
class UnmodifiableInt64ListView extends UnmodifiableListBase<int>
with _UnmodifiableListMixin<int, Int64List, Int64List>
implements Int64List {
@@ -260,6 +293,9 @@
}
/// View of a [Int32x4List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableInt32x4ListView.
class UnmodifiableInt32x4ListView extends UnmodifiableListBase<Int32x4>
with _UnmodifiableListMixin<Int32x4, Int32x4List, Int32x4List>
implements Int32x4List {
@@ -270,6 +306,9 @@
}
/// View of a [Float32x4List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableFloat32x4ListView.
class UnmodifiableFloat32x4ListView extends UnmodifiableListBase<Float32x4>
with _UnmodifiableListMixin<Float32x4, Float32x4List, Float32x4List>
implements Float32x4List {
@@ -280,6 +319,9 @@
}
/// View of a [Float64x2List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableFloat64x2ListView.
class UnmodifiableFloat64x2ListView extends UnmodifiableListBase<Float64x2>
with _UnmodifiableListMixin<Float64x2, Float64x2List, Float64x2List>
implements Float64x2List {
@@ -290,6 +332,9 @@
}
/// View of a [Float32List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableFloat32ListView.
class UnmodifiableFloat32ListView extends UnmodifiableListBase<double>
with _UnmodifiableListMixin<double, Float32List, Float32List>
implements Float32List {
@@ -300,6 +345,9 @@
}
/// View of a [Float64List] that disallows modification.
+///
+/// It is a compile-time error for a class to attempt to extend or implement
+/// UnmodifiableFloat64ListView.
class UnmodifiableFloat64ListView extends UnmodifiableListBase<double>
with _UnmodifiableListMixin<double, Float64List, Float64List>
implements Float64List {