[lib] Update SendPort.send documentation

Try to make it more clear that you can only send default
implementations of List, Map, Set, etc.

Add CHANGELOG.md entry that documents a8fe399c79

Related to https://github.com/dart-lang/sdk/issues/50594

Change-Id: Ib0cf9d389b91cc5ab72b8bab5461ee91037baf25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273185
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
This commit is contained in:
Vyacheslav Egorov 2022-12-19 16:03:46 +00:00 committed by Commit Queue
parent 9306752ba7
commit 13978f85fd
2 changed files with 28 additions and 12 deletions

View file

@ -256,6 +256,16 @@ Updates the Linter to `1.32.0`, which includes changes that
#### `dart:isolate`
- Add `Isolate.run` to run a function in a new isolate.
- **Breaking change**: `SendPort.send` is again applying strict checks to the
contents of the message when sending messages between isolates that are not
known to share the same code (e.g. an isolate spawned via `Isolate.spawnUri`).
These checks were accidentally relaxed in an earlier Dart version allowing
all classes from `dart:core` and `dart:collection` through. This for
example means that you can't send an instance of a `HashMap` to an isolate
spawned via `Isolate.spawnUri`. See [`SendPort.send`] documentation for
the full list of restrictions.
[`SendPort.send`]: https://api.dart.dev/stable/dart-isolate/SendPort/send.html
#### `dart:mirrors`

View file

@ -707,18 +707,24 @@ abstract class SendPort implements Capability {
/// Sends an asynchronous [message] through this send port, to its
/// corresponding [ReceivePort].
///
/// The transitive object graph of [message] can contain the following
/// objects:
/// - [Null]
/// - [bool]
/// - [int]
/// - [double]
/// - [String]
/// - [List], [Map] or [Set] (whose elements are any of these)
/// If the sending and receiving isolates do not share the same code
/// (an isolate created using [Isolate.spawnUri] does not share the code
/// of the isolate that spawned it), the transitive object graph of [message]
/// can **only** contain the following kinds of objects:
///
/// - `null`
/// - `true` and `false`
/// - Instances of [int], [double], [String]
/// - Instances created through list, map and set literals
/// - Instances created by constructors of:
/// - [List], [Map], [LinkedHashMap], [Set] and [LinkedHashSet]
/// - [TransferableTypedData]
/// - [SendPort]
/// - [Capability]
/// - [Type] representing one of these types, Object, dynamic, void or Never
/// - [SendPort] instances returned by [ReceivePort]'s `sendPort` getter
/// - Instances of [Type] representing one of the types mentioned above,
/// `Object`, `dynamic`, `void` and `Never` as well as nullable variants
/// of all these types. For generic types type arguments must be sendable
/// types for the whole type to be sendable.
///
/// If the sender and receiver isolate share the same code (e.g. isolates
/// created via [Isolate.spawn]), the transitive object graph of [message] can