Reapply "[typed_data] Deprecate unmodifiable views"
This change, for Dart 3.4, deprecates the unmodifiable typed data constructors. Users of these constructors can upgrade the use of the constructors to instance method `asUnmodifiableView()`, or pin to Dart 3.3.
See https://github.com/dart-lang/sdk/issues/53785 for context.
CoreLibraryReviewExempt: Reviewed in https://dart-review.googlesource.com/c/sdk/+/321922
Issue: #53785
Change-Id: Icd52f2b6cd05cf3a328c82c197ef44d0b340b171
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332581
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f12fd9f..81d22ef 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -39,6 +39,29 @@
[#54138]: https://github.com/dart-lang/sdk/issues/54138
+#### `dart:typed_data`
+
+- **BREAKING CHANGE** [#53218][] [#53785][]: The unmodifiable view classes for
+ typed data are deprecated.
+
+ To create an unmodifiable view of a typed-data object, use the
+ `asUnmodifiableView()` methods added in Dart 3.3:
+
+ ```dart
+ Uint8List data = ...;
+ final readOnlyView = data.asUnmodifiableView();
+ // readOnlyView has type Uint8List, and throws if attempted modified.
+ ```
+
+ The reason for this change is to allow more flexibility in the implementation
+ of typed data, so the native and web platforms can use different strategies
+ to ensure that typed data has good performance.
+
+ The deprecated types will be removed in Dart 3.5.
+
+[#53218]: https://github.com/dart-lang/sdk/issues/53218
+[#53785]: https://github.com/dart-lang/sdk/issues/53785
+
## 3.3.0
### Language
diff --git a/sdk/lib/typed_data/unmodifiable_typed_data.dart b/sdk/lib/typed_data/unmodifiable_typed_data.dart
index 7cfd765..79f5323 100644
--- a/sdk/lib/typed_data/unmodifiable_typed_data.dart
+++ b/sdk/lib/typed_data/unmodifiable_typed_data.dart
@@ -8,7 +8,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableByteBufferView.
-// TODO(53785): @Deprecated('No replacement')
+@Deprecated('No replacement')
abstract final class UnmodifiableByteBufferView implements ByteBuffer {
external factory UnmodifiableByteBufferView(ByteBuffer data);
}
@@ -17,7 +17,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableByteDataView.
-// TODO(53785): @Deprecated('Use ByteData.asUnmodifiableView() instead')
+@Deprecated('Use ByteData.asUnmodifiableView() instead')
abstract final class UnmodifiableByteDataView implements ByteData {
external factory UnmodifiableByteDataView(ByteData data);
}
@@ -26,7 +26,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableUint8ListView.
-// TODO(53785): @Deprecated('Use Uint8List.asUnmodifiableView() instead')
+@Deprecated('Use Uint8List.asUnmodifiableView() instead')
abstract final class UnmodifiableUint8ListView implements Uint8List {
external factory UnmodifiableUint8ListView(Uint8List list);
}
@@ -35,7 +35,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableInt8ListView.
-// TODO(53785): @Deprecated('Use Int8List.asUnmodifiableView() instead')
+@Deprecated('Use Int8List.asUnmodifiableView() instead')
abstract final class UnmodifiableInt8ListView implements Int8List {
external factory UnmodifiableInt8ListView(Int8List list);
}
@@ -44,7 +44,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableUint8ClampedListView.
-// TODO(53785): @Deprecated('Use Uint8ClampedList.asUnmodifiableView() instead')
+@Deprecated('Use Uint8ClampedList.asUnmodifiableView() instead')
abstract final class UnmodifiableUint8ClampedListView
implements Uint8ClampedList {
external factory UnmodifiableUint8ClampedListView(Uint8ClampedList list);
@@ -54,7 +54,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableUint16ListView.
-// TODO(53785): @Deprecated('Use Uint16List.asUnmodifiableView() instead')
+@Deprecated('Use Uint16List.asUnmodifiableView() instead')
abstract final class UnmodifiableUint16ListView implements Uint16List {
external factory UnmodifiableUint16ListView(Uint16List list);
}
@@ -63,7 +63,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableInt16ListView.
-// TODO(53785): @Deprecated('Use Int16List.asUnmodifiableView() instead')
+@Deprecated('Use Int16List.asUnmodifiableView() instead')
abstract final class UnmodifiableInt16ListView implements Int16List {
external factory UnmodifiableInt16ListView(Int16List list);
}
@@ -72,7 +72,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableUint32ListView.
-// TODO(53785): @Deprecated('Use Uint32List.asUnmodifiableView() instead')
+@Deprecated('Use Uint32List.asUnmodifiableView() instead')
abstract final class UnmodifiableUint32ListView implements Uint32List {
external factory UnmodifiableUint32ListView(Uint32List list);
}
@@ -81,7 +81,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableInt32ListView.
-// TODO(53785): @Deprecated('Use Int32List.asUnmodifiableView() instead')
+@Deprecated('Use Int32List.asUnmodifiableView() instead')
abstract final class UnmodifiableInt32ListView implements Int32List {
external factory UnmodifiableInt32ListView(Int32List list);
}
@@ -90,7 +90,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableUint64ListView.
-// TODO(53785): @Deprecated('Use Uint64List.asUnmodifiableView() instead')
+@Deprecated('Use Uint64List.asUnmodifiableView() instead')
abstract final class UnmodifiableUint64ListView implements Uint64List {
external factory UnmodifiableUint64ListView(Uint64List list);
}
@@ -99,7 +99,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableInt64ListView.
-// TODO(53785): @Deprecated('Use Int64List.asUnmodifiableView() instead')
+@Deprecated('Use Int64List.asUnmodifiableView() instead')
abstract final class UnmodifiableInt64ListView implements Int64List {
external factory UnmodifiableInt64ListView(Int64List list);
}
@@ -108,7 +108,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableInt32x4ListView.
-// TODO(53785): @Deprecated('Use Int32x4List.asUnmodifiableView() instead')
+@Deprecated('Use Int32x4List.asUnmodifiableView() instead')
abstract final class UnmodifiableInt32x4ListView implements Int32x4List {
external factory UnmodifiableInt32x4ListView(Int32x4List list);
}
@@ -117,7 +117,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableFloat32x4ListView.
-// TODO(53785): @Deprecated('Use Float32x4List.asUnmodifiableView() instead')
+@Deprecated('Use Float32x4List.asUnmodifiableView() instead')
abstract final class UnmodifiableFloat32x4ListView implements Float32x4List {
external factory UnmodifiableFloat32x4ListView(Float32x4List list);
}
@@ -126,7 +126,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableFloat64x2ListView.
-// TODO(53785): @Deprecated('Use Float64x2List.asUnmodifiableView() instead')
+@Deprecated('Use Float64x2List.asUnmodifiableView() instead')
abstract final class UnmodifiableFloat64x2ListView implements Float64x2List {
external factory UnmodifiableFloat64x2ListView(Float64x2List list);
}
@@ -135,7 +135,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableFloat32ListView.
-// TODO(53785): @Deprecated('Use Float32List.asUnmodifiableView() instead')
+@Deprecated('Use Float32List.asUnmodifiableView() instead')
abstract final class UnmodifiableFloat32ListView implements Float32List {
external factory UnmodifiableFloat32ListView(Float32List list);
}
@@ -144,7 +144,7 @@
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableFloat64ListView.
-// TODO(53785): @Deprecated('Use Float64List.asUnmodifiableView() instead')
+@Deprecated('Use Float64List.asUnmodifiableView() instead')
abstract final class UnmodifiableFloat64ListView implements Float64List {
external factory UnmodifiableFloat64ListView(Float64List list);
}