Version 2.12.1
* Cherry-pick ea3dfc9ac4617ad0346b515596636a1089ecc8a1 to stable
* Cherry-pick eb6b474d7a8c0d34b536a803f9752b9429629259 to stable
* Cherry-pick d9361f711206dee4b0b15b4eb4674a6272257969 to stable
* Cherry-pick e962528c413683d79e6141f72367d7f97d858759 to stable
* Cherry-pick 29c2197712c513de980db0ce02b91b0165e665d0 to stable
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 75ddaaa..69fe269 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,71 +1,95 @@
-## 2.12.0
+## 2.12.1 - 2021-03-10
+
+This is a patch release that fixes:
+
+* an unhandled exception in HTTPS connections (issue [#45047][]).
+* a typing issue in the typed_data `+` operator (issue [#45140][]).
+
+[#45047]: https://github.com/dart-lang/sdk/issues/45047
+[#45140]: https://github.com/dart-lang/sdk/issues/45140
+
+## 2.12.0 - 2021-03-03
### Language
-* **Breaking Change** [Null
- Safety](https://dart.dev/null-safety/understanding-null-safety) is now
- enabled by default in all packages with a lower sdk constraint of 2.12.0 or
- greater. Files that are not subject to language versioning (whether because
- they are not contained in a pub package, or because the package that they
- are contained in has no lower sdk constraint) are treated as opted into to
- null safety by default and may report new errors. Pub packages may be opted
- out of null safety by setting a min sdk constraint in pubspec.yaml of 2.9.0
- or less. Files may be opted out of null safety by adding `// @dart=2.9` to
- the beginning of the file.
+* **Breaking Change** [Null safety][] is now enabled by default in all code
+ that has not opted out. With null safety, types in your code are
+ non-nullable by default. Null can only flow into parts of your program where
+ you want it. With null safety, your runtime null-dereference bugs turn into
+ edit-time analysis errors.
+
+ You can opt out of null safety and preserve your code's previous behavior by
+ setting the lower bound of the SDK constraint in your pubspec to 2.11.0 or
+ earlier to request an earlier [language version][]. You can opt out
+ individual Dart files by adding `// @dart=2.11` to the beginning of the
+ file.
+
+ Files that are opted in to null safety may report new compile-time errors.
+ Opting in to null safety also gives you access to other new language
+ features:
+
+ * Smarter flow analysis and type promotion
+ * `required` named parameters
+ * `late` variables
+ * The postfix `!` null assertion operator
+ * The `?..` and `?[]` null-aware operators
* **Breaking Change** [#44660][]: Fixed an implementation bug where `this`
would sometimes undergo type promotion in extensions.
+[null safety]: https://dart.dev/null-safety/understanding-null-safety
+[language version]: https://dart.dev/guides/language/evolution#language-versioning
[#44660]: https://github.com/dart-lang/sdk/issues/44660
### Core libraries
#### `dart:async`
-* Adds extension method `onError` on `Future` to allow better typing
- of error handling.
+* Add extension method `onError()` on `Future` to allow better typing of error
+ callbacks.
#### `dart:collection`
-* Added `UnmodifiableSetView` class, which allows users to guarantee that
- methods that could change underlying `Set` instance can not be invoked.
+* Add `UnmodifiableSetView` class, which allows users to guarantee that
+ methods that could change underlying `Set` instance can not be invoked.
-* `LinkedList` made it explicit that elements are compared by identity,
- and updated `contains` to take advantage of this.
+* Make it explicit that `LinkedList` compares elements by identity, and update
+ `contains()` to take advantage of this.
#### `dart:core`
-* Added `unmodifiable` constructor to class `Set`, which allows users to create
- unmodifiable `Set` instances.
+* Add `Set.unmodifiable()` constructor, which allows users to create
+ unmodifiable `Set` instances.
#### `dart:io`
-* `HttpRequest` will now correctly follow HTTP 308 redirects
- (`HttpStatus.permanentRedirect`).
+* `HttpRequest` now correctly follows HTTP 308 redirects
+ (`HttpStatus.permanentRedirect`).
#### `dart:isolate`
-* Added `debugName` positional parameter to `ReceivePort` and `RawReceivePort`
- constructors, a name which can be associated with the port and displayed in
- tooling.
+* Add `debugName` positional parameter to `ReceivePort` and `RawReceivePort`
+ constructors, a name which can be associated with the port and displayed in
+ tooling.
#### `dart:html`
-* `EventStreamSubscription.cancel` has been updated to retain its synchronous
- timing when running in both sound and unsound null safety modes. See issue
- [#44157][] for more details.
+* `EventStreamSubscription.cancel` has been updated to retain its synchronous
+ timing when running in both sound and unsound null safety modes. See issue
+ [#44157][] for more details.
[#44157]: https://github.com/dart-lang/sdk/issues/44157
### Dart VM
-* **Breaking Change** [#42312][]: `Dart_WeakPersistentHandle`s will no longer
+* **Breaking Change** [#42312][]: `Dart_WeakPersistentHandle`s no longer
auto-delete themselves when the referenced object is garbage collected to
avoid race conditions, but they are still automatically deleted when the
isolate group shuts down.
+
* **Breaking Change** [#42312][]: `Dart_WeakPersistentHandleFinalizer`
is renamed to `Dart_HandleFinalizer` and had its `handle` argument removed.
- All api functions using that type have been updated.
+ All API functions using that type have been updated.
[#42312]: https://github.com/dart-lang/sdk/issues/42312
@@ -80,6 +104,7 @@
Instead, the `Allocator` it is introduced to `dart:ffi`, and also requires
a constant `T` on invocations. For migration notes see the breaking change
request.
+
* **Breaking Change** [#44622][]: Subtypes of `Struct` without any native
member are being deprecated in the current stable release (2.12), and are
planned to be fully removed in the following stable release (2.13).
@@ -90,160 +115,198 @@
### Dart2JS
-* Removed `--no-defer-class-types` and `--no-new-deferred-split`.
+* Remove `--no-defer-class-types` and `--no-new-deferred-split`.
### Tools
#### Dartanalyzer
-* Removed the `--use-fasta-parser`, `--preview-dart-2`, and
- `--enable-assert-initializers` command line options. These options haven't
- been supported in a while and were no-ops.
-* Report diagnostics regarding the
- [`@internal`](https://pub.dev/documentation/meta/latest/meta/internal-constant.html)
- annotation.
-* Improve diagnostic-reporting regarding the
- [`@doNotStore`](https://pub.dev/documentation/meta/latest/meta/doNotStore-constant.html)
- annotation.
-* Introduce a diagnostic which is reported when a library member named `main`
- is not a function.
-* Introduce a diagnostic which is reported when a `main` function's first
- parameter is not a supertype of `List<String>`.
-* Introduce a diagnostic which is reported when an `// ignore` comment contains
- an error code which is not being reported.
-* Introduce a diagnostic which is reported when an `// ignore` comment contains
- an error code which cannot be ignored.
-* Introduce a diagnostic which is reported when an `// ignore` comment contains
- an error code which is already being ignored.
-* Report diagnostics when using
- [`@visibleForTesting`](https://pub.dev/documentation/meta/latest/meta/visibleForTesting-constant.html)
- on top-level variables.
-* Fix false positive reports of "unused element" for top-level setters and
- getters.
-* Fix false positive reports regarding `@deprecated` field formal parameters at
- their declaration.
-* For null safety, introduce a diagnostic which reports when a null-check will
- always fail.
-* Fix false positive reports regarding optional parameters on privat
- constructors being unused.
-* Introduce a diagnostic which is reported when a constructor includes
- duplicate field formal parameters.
-* Improve the "unused import" diagnostic when multiple import directives share
- a common prefix.
-* Fix false positive "unused import" diagnostic regarding an import which
- provides an extension method which is used.
-* For null safety, improve the messaging of "use of nullable value" diagnostics
- for eight different contexts.
-* Fix false positive reports regarding `@visibleForTesting` members in a "hide"
- combinator of an import or export directive.
-* Improve the messaging of "invalid override" diagnostics.
-* Introduce a diagnostic which is reported when `Future<T>.catchError` is
- called with an `onError` callback which does not return `FutureOr<T>`.
+* Remove the `--use-fasta-parser`, `--preview-dart-2`, and
+ `--enable-assert-initializers` command line options. These options haven't
+ been supported in a while and were no-ops.
+
+* Report diagnostics regarding the
+ [`@internal`](https://pub.dev/documentation/meta/latest/meta/internal-constant.html)
+ annotation.
+
+* Improve diagnostic-reporting regarding the
+ [`@doNotStore`](https://pub.dev/documentation/meta/latest/meta/doNotStore-constant.html)
+ annotation.
+
+* Introduce a diagnostic which is reported when a library member named `main`
+ is not a function.
+
+* Introduce a diagnostic which is reported when a `main` function's first
+ parameter is not a supertype of `List<String>`.
+
+* Introduce diagnostics for when an `// ignore` comment contains an error code
+ which is not being reported, cannot be ignored, or is already being ignored.
+
+* Report diagnostics when using
+ [`@visibleForTesting`](https://pub.dev/documentation/meta/latest/meta/
+ visibleForTesting-constant.html) on top-level variables.
+
+* Fix false positive reports of "unused element" for top-level setters and
+ getters.
+
+* Fix false positive reports regarding `@deprecated` field formal parameters
+ at their declaration.
+
+* For null safety, introduce a diagnostic which reports when a null-check will
+ always fail.
+
+* Fix false positive reports regarding optional parameters on private
+ constructors being unused.
+
+* Introduce a diagnostic which is reported when a constructor includes
+ duplicate field formal parameters.
+
+* Improve the "unused import" diagnostic when multiple import directives share
+ a common prefix.
+
+* Fix false positive "unused import" diagnostic regarding an import which
+ provides an extension method which is used.
+
+* For null safety, improve the messaging of "use of nullable value"
+ diagnostics for eight different contexts.
+
+* Fix false positive reports regarding `@visibleForTesting` members in a
+ "hide" combinator of an import or export directive.
+
+* Improve the messaging of "invalid override" diagnostics.
+
+* Introduce a diagnostic which is reported when `Future<T>.catchError` is
+ called with an `onError` callback which does not return `FutureOr<T>`.
#### dartfmt
-* Don't duplicate comments on chained if elements.
-* Preserve `?` in initializing formal function-typed parameters.
+* Don't duplicate comments on chained if elements.
+
+* Preserve `?` in initializing formal function-typed parameters.
+
+* Fix performance issue with constructors that have no initializer list.
#### Linter
Updated the Linter to `0.1.129`, which includes:
-* New lint: `avoid_dynamic_calls`.
-* (Internal): `avoid_type_to_string` updated to use `addArgumentList` registry API.
-* Miscellaneous documentation improvements.
-* Fixed crash in `prefer_collection_literals` when there is no static parameter
- element.
-* Fixed false negatives for `prefer_collection_literals` when a LinkedHashSet or
- LinkedHashMap instantiation is passed as the argument to a function in any
- position other than the first.
-* Fixed false negatives for `prefer_collection_literals` when a LinkedHashSet or
- LinkedHashMap instantiation is used in a place with a static type other than
- Set or Map.
-* (Internal): test updates to the new `PhysicalResourceProvider` API.
-* Fixed false positives in `prefer_constructors_over_static_methods`.
-* Updates to `package_names` to allow leading underscores.
-* Fixed NPEs in `unnecessary_null_checks`.
-* A fixed NPE in `missing_whitespace_between_adjacent_strings`.
-* Updates to `void_checks` for NNBD.
-* A fixed range error in `unnecessary_string_escapes`.
-* A fixed false positives in `unnecessary_null_types`.
-* Fixes to `prefer_constructors_over_static_methods` to respect type parameters.
-* Updates to `always_require_non_null_named_parameters` to be NNBD-aware.
-* Updates tp `unnecessary_nullable_for_final_variable_declarations` to allow dynamic.
-* Updates `overridden_fields` to not report on abstract parent fields.
-* Fixes to `unrelated_type_equality_checks` for NNBD.
-* Improvements to `type_init_formals`to allow types not equal to the field type.
-* Performance improvements to `always_use_package_imports`,
- `avoid_renaming_method_parameters`, `prefer_relative_imports` and
- `public_member_api_docs`.
-* (internal): updates to analyzer `0.40.4` APIs
-* New lint: `cast_nullable_to_non_nullable`.
-* New lint: `null_check_on_nullable_type_parameter`.
-* New lint: `tighten_type_of_initializing_formals`.
-* Updates to `public_member_apis` to check generic type aliases.
-* (Internal): updates to adopt new analyzer APIs.
-* Fixed `close_sinks` to handle `this`-prefixed property accesses.
-* New lint: `unnecessary_null_checks`.
-* Fixed `unawaited_futures` to handle `Future` subtypes.
-* New lint: `avoid_type_to_string`.
+* New lints: `avoid_dynamic_calls`, `cast_nullable_to_non_nullable`,
+ `null_check_on_nullable_type_parameter`,
+ `tighten_type_of_initializing_formals`, `unnecessary_null_checks`, and
+ `avoid_type_to_string`.
+
+* Fix crash in `prefer_collection_literals` when there is no static parameter
+ element.
+
+* Fix false negatives for `prefer_collection_literals` when a LinkedHashSet or
+ LinkedHashMap instantiation is passed as the argument to a function in any
+ position other than the first.
+
+* Fix false negatives for `prefer_collection_literals` when a LinkedHashSet or
+ LinkedHashMap instantiation is used in a place with a static type other than
+ Set or Map.
+
+* Update to `package_names` to allow leading underscores.
+
+* Fix crashes in `unnecessary_null_checks` and
+ `missing_whitespace_between_adjacent_strings`.
+
+* Update to `void_checks` for null safety.
+
+* Fix range error in `unnecessary_string_escapes`.
+
+* Fix false positives in `unnecessary_null_types`.
+
+* Fix to `prefer_constructors_over_static_methods` to respect type
+ parameters.
+
+* Update to `always_require_non_null_named_parameters` to be null safety-aware.
+
+* Update to `unnecessary_nullable_for_final_variable_declarations` to allow
+ dynamic.
+
+* Update `overridden_fields` to not report on abstract parent fields.
+
+* Fix to `unrelated_type_equality_checks` for null safety.
+
+* Improvements to `type_init_formals`to allow types not equal to the field
+ type.
+
+* Updates to `public_member_apis` to check generic type aliases.
+
+* Fix `close_sinks` to handle `this`-prefixed property accesses.
+
+* Fix `unawaited_futures` to handle `Future` subtypes.
+
+* Performance improvements to `always_use_package_imports`,
+ `avoid_renaming_method_parameters`, `prefer_relative_imports` and
+ `public_member_api_docs`.
#### Pub
-* **Breaking**: The Dart SDK constraint is now **required** in `pubspec.yaml`.
+* **Breaking**: The Dart SDK constraint is now **required** in `pubspec.yaml`.
+ You must include a section like:
- You now have to include a section like:
+ ```yaml
+ environment:
+ sdk: '>=2.10.0 <3.0.0'
+ ```
- ```yaml
- environment:
- sdk: '>=2.10.0 <3.0.0'
- ```
+ See [#44072][].
- See [#44072][].
+ For legacy dependencies without an SDK constraint, pub will now assume a
+ default language version of 2.7.
- For legacy dependencies without an sdk constraint pub will now assume a
- default language version of 2.7.
-* The top level `pub` executable has been deprecated. Use `dart pub` instead.
- See [dart tool][].
-* New command `dart pub add` that adds new dependencies to your `pubspec.yaml`.
+* The top level `pub` executable has been deprecated. Use `dart pub` instead.
+ See [dart tool][].
- And a corresponding `dart pub remove` that removes dependencies.
-* New option `dart pub upgrade --major-versions` will update constraints in
- your `pubspec.yaml` to match the the _resolvable_ column reported in
- `dart pub outdated`. This allows users to easily upgrade to latest version for
- all dependencies where this is possible, even if such upgrade requires an
- update to the version constraint in `pubspec.yaml`.
+* New command `dart pub add` that adds new dependencies to your
+ `pubspec.yaml`, and a corresponding `dart pub remove` that removes
+ dependencies.
- It is also possible to only upgrade the major version for a subset of your
- dependencies using `dart pub upgrade --major-versions <dependencies...>`.
-* New option `dart pub upgrade --null-safety` will attempt to update constraints
- in your `pubspec.yaml`, such that only null-safety migrated versions of
- dependencies are allowed.
-* New option `dart pub outdated --mode=null-safety` that will analyze your
- dependencies for null-safety.
-* `dart pub get` and `dart pub upgrade` will highlight dependencies that have
- been [discontinued](https://dart.dev/tools/pub/publishing#discontinue) on
- pub.dev.
-* `dart pub publish` will now check your pubspec keys for likely typos.
-* `dart pub upgrade package_foo` will fetch dependencies, but ignore the
- `pubspec.lock` for `package_foo`, allowing users to only upgrade a subset of
- dependencies.
-* New command `dart pub login` that logs in to pub.dev.
-* The `--server` option to `dart pub publish` and `dart pub uploader` have been
- deprecated. Use `publish_to` in your `pubspec.yaml` or set the
- `$PUB_HOSTED_URL` environment variable.
-* `pub global activate no longer re-precompiles if current global installed was
- same version.
-* The Flutter SDK constraint upper bound is now ignored in pubspecs and
- deprecated when publishing.
+* New option `dart pub upgrade --major-versions` will update constraints in
+ your `pubspec.yaml` to match the the _resolvable_ column reported in `dart
+ pub outdated`. This allows users to easily upgrade to latest version for all
+ dependencies where this is possible, even if such upgrade requires an update
+ to the version constraint in `pubspec.yaml`.
- See: [flutter-upper-bound-deprecation][].
+ It is also possible to only upgrade the major version for a subset of your
+ dependencies using `dart pub upgrade --major-versions <dependencies...>`.
+
+* New option `dart pub upgrade --null-safety` will attempt to update constraints
+ in your `pubspec.yaml`, such that only null-safety migrated versions of
+ dependencies are allowed.
+
+* New option `dart pub outdated --mode=null-safety` that will analyze your
+ dependencies for null-safety.
+
+* `dart pub get` and `dart pub upgrade` will highlight dependencies that have
+ been [discontinued](https://dart.dev/tools/pub/publishing#discontinue) on
+ pub.dev.
+
+* `dart pub publish` will now check your pubspec keys for likely typos.
+
+* `dart pub upgrade package_foo` fetchs dependencies but ignores the
+ `pubspec.lock` for `package_foo`, allowing users to only upgrade a subset of
+ dependencies.
+
+* New command `dart pub login` that logs in to pub.dev.
+
+* The `--server` option to `dart pub publish` and `dart pub uploader` are
+ deprecated. Use `publish_to` in your `pubspec.yaml` or set the
+ `$PUB_HOSTED_URL` environment variable.
+
+* `pub global activate` no longer re-precompiles if the current global
+ installation was same version.
+
+* The Flutter SDK constraint upper bound is now ignored in pubspecs and
+ deprecated when publishing. See: [flutter-upper-bound-deprecation][].
[flutter-upper-bound-deprecation]: https://dart.dev/go/flutter-upper-bound-deprecation
[#44072]: https://github.com/dart-lang/sdk/issues/44072
[dart tool]: https://dart.dev/tools/dart-tool
-## 2.10.5 - 2020-01-21
+## 2.10.5 - 2021-01-21
This is a patch release that fixes a crash in the Dart VM. (issue [#44563][]).
@@ -608,7 +671,7 @@
* **Breaking change** [#40681][]: The `runZoned()` function is split into two
functions: `runZoned()` and `runZonedGuarded()`, where the latter has a
required `onError` parameter, and the former has none. This prepares the
- functions for Null Safety where the two functions will differ in the
+ functions for null safety where the two functions will differ in the
nullability of their return types.
* **Breaking change** [#40683][]: Errors passed to
diff --git a/runtime/tests/vm/dart/regress45047_test.dart b/runtime/tests/vm/dart/regress45047_test.dart
new file mode 100644
index 0000000..4d2f083
--- /dev/null
+++ b/runtime/tests/vm/dart/regress45047_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2021, 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.
+
+// Verify that socket connection gracefully closes if cancelled.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:expect/expect.dart';
+
+void main() async {
+ final task = await Socket.startConnect('google.com', 80);
+ task.cancel();
+ try {
+ await task.socket;
+ } catch (e) {
+ Expect.isTrue(e is SocketException);
+ final socketException = e as SocketException;
+ Expect.isTrue(
+ socketException.message.startsWith('Connection attempt cancelled'));
+ }
+}
diff --git a/runtime/tests/vm/dart_2/regress45047_test.dart b/runtime/tests/vm/dart_2/regress45047_test.dart
new file mode 100644
index 0000000..4d2f083
--- /dev/null
+++ b/runtime/tests/vm/dart_2/regress45047_test.dart
@@ -0,0 +1,23 @@
+// Copyright (c) 2021, 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.
+
+// Verify that socket connection gracefully closes if cancelled.
+
+import 'dart:async';
+import 'dart:io';
+
+import 'package:expect/expect.dart';
+
+void main() async {
+ final task = await Socket.startConnect('google.com', 80);
+ task.cancel();
+ try {
+ await task.socket;
+ } catch (e) {
+ Expect.isTrue(e is SocketException);
+ final socketException = e as SocketException;
+ Expect.isTrue(
+ socketException.message.startsWith('Connection attempt cancelled'));
+ }
+}
diff --git a/sdk/lib/_internal/vm/bin/socket_patch.dart b/sdk/lib/_internal/vm/bin/socket_patch.dart
index fb9e7a9..339d9a7 100644
--- a/sdk/lib/_internal/vm/bin/socket_patch.dart
+++ b/sdk/lib/_internal/vm/bin/socket_patch.dart
@@ -844,7 +844,10 @@
}
connecting.clear();
addressesSubscription.cancel();
- result.complete(socket);
+ if (!result.isCompleted) {
+ // Might be already completed via onCancel
+ result.complete(socket);
+ }
}, error: (e, st) {
connecting.remove(socket);
socket.close();
@@ -864,6 +867,7 @@
s.setHandlers();
s.setListening(read: false, write: false);
}
+ addressesSubscription.cancel();
connecting.clear();
if (!result.isCompleted) {
error ??= createError(
diff --git a/sdk/lib/_internal/vm/lib/typed_data_patch.dart b/sdk/lib/_internal/vm/lib/typed_data_patch.dart
index d608ab6..b0c18d5 100644
--- a/sdk/lib/_internal/vm/lib/typed_data_patch.dart
+++ b/sdk/lib/_internal/vm/lib/typed_data_patch.dart
@@ -150,13 +150,7 @@
return -1;
}
- List<int> operator +(List<int> other) {
- int totalLength = this.length + other.length;
- return <int>[]
- ..length = totalLength
- ..setRange(0, this.length, this)
- ..setRange(this.length, totalLength, other);
- }
+ List<int> operator +(List<int> other) => [...this, ...other];
bool contains(Object? element) {
var len = this.length;
@@ -506,13 +500,7 @@
return -1;
}
- List<double> operator +(List<double> other) {
- int totalLength = this.length + other.length;
- return <double>[]
- ..length = totalLength
- ..setRange(0, this.length, this)
- ..setRange(this.length, totalLength, other);
- }
+ List<double> operator +(List<double> other) => [...this, ...other];
bool contains(Object? element) {
var len = this.length;
@@ -868,13 +856,7 @@
return -1;
}
- List<Float32x4> operator +(List<Float32x4> other) {
- int totalLength = this.length + other.length;
- return <Float32x4>[]
- ..length = totalLength
- ..setRange(0, this.length, this)
- ..setRange(this.length, totalLength, other);
- }
+ List<Float32x4> operator +(List<Float32x4> other) => [...this, ...other];
bool contains(Object? element) {
var len = this.length;
@@ -1228,13 +1210,7 @@
return -1;
}
- List<Int32x4> operator +(List<Int32x4> other) {
- int totalLength = this.length + other.length;
- return <Int32x4>[]
- ..length = totalLength
- ..setRange(0, this.length, this)
- ..setRange(this.length, totalLength, other);
- }
+ List<Int32x4> operator +(List<Int32x4> other) => [...this, ...other];
bool contains(Object? element) {
var len = this.length;
@@ -1587,13 +1563,7 @@
return -1;
}
- List<Float64x2> operator +(List<Float64x2> other) {
- int totalLength = this.length + other.length;
- return <Float64x2>[]
- ..length = totalLength
- ..setRange(0, this.length, this)
- ..setRange(this.length, totalLength, other);
- }
+ List<Float64x2> operator +(List<Float64x2> other) => [...this, ...other];
bool contains(Object? element) {
var len = this.length;
diff --git a/tests/lib/typed_data/regression_45140_test.dart b/tests/lib/typed_data/regression_45140_test.dart
new file mode 100644
index 0000000..864ce45
--- /dev/null
+++ b/tests/lib/typed_data/regression_45140_test.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2021, 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.
+
+import 'dart:math' show Random;
+import 'dart:typed_data';
+import 'package:expect/expect.dart';
+
+void main() {
+ var r = Random();
+ int genInt() => r.nextInt(256);
+ double genDbl() => r.nextDouble();
+ Int32x4 genIx4() => Int32x4(genInt(), genInt(), genInt(), genInt());
+ Float32x4 genFx4() => Float32x4(genDbl(), genDbl(), genDbl(), genDbl());
+ Float64x2 genDx2() => Float64x2(genDbl(), genDbl());
+
+ test("Uint8List", (n) => Uint8List(n)..fill(genInt));
+ test("Uint16List", (n) => Uint16List(n)..fill(genInt));
+ test("Uint32List", (n) => Uint32List(n)..fill(genInt));
+ test("Int8List", (n) => Int8List(n)..fill(genInt));
+ test("Int16List", (n) => Int16List(n)..fill(genInt));
+ test("Int32List", (n) => Int32List(n)..fill(genInt));
+ test("Uint8ClampedList", (n) => Uint8ClampedList(n)..fill(genInt));
+ test("Float32List", (n) => Float32List(n)..fill(genDbl));
+ test("Float64List", (n) => Float64List(n)..fill(genDbl));
+ test("Int32x4List", (n) => Int32x4List(n)..fill(genIx4));
+ test("Float32x4List", (n) => Float32x4List(n)..fill(genFx4));
+ test("Float64x2List", (n) => Float64x2List(n)..fill(genDx2));
+}
+
+void test<T>(String name, List<T> create(int n)) {
+ var l1 = create(17);
+ var l2 = create(13);
+ List<T> l3;
+ try {
+ // Shouldn't throw:
+ l3 = l1 + l2;
+ } catch (e) {
+ // Until we change Expect.fail to return Never.
+ Expect.fail("$name: $e") as Never;
+ }
+ Expect.equals(30, l3.length);
+ if (0 is T || 0.0 is T) {
+ // Int32x4 etc. do not support `==`.
+ Expect.listEquals(l1, l3.sublist(0, 17), "$name first");
+ Expect.listEquals(l2, l3.sublist(17), "$name second");
+ }
+ // Result is growable, shouldn't throw.
+ try {
+ l3.add(l3.first);
+ } catch (e) {
+ Expect.fail("$name: $e");
+ }
+}
+
+// Fill a list with (random) generated values.
+extension<T> on List<T> {
+ void fill(T gen()) {
+ for (var i = 0; i < length; i++) {
+ this[i] = gen();
+ }
+ }
+}
diff --git a/tools/VERSION b/tools/VERSION
index 353167a..7b54af4 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -26,6 +26,6 @@
CHANNEL stable
MAJOR 2
MINOR 12
-PATCH 0
+PATCH 1
PRERELEASE 0
PRERELEASE_PATCH 0
\ No newline at end of file