1
0
mirror of https://github.com/dart-lang/sdk synced 2024-07-05 17:30:16 +00:00

[dart2wasm] Port VM fix for #52083 (sync*)

dart2wasm's sync* runtime library was mostly copied from VM, but we
didn't get the fix for #52083 in 9cf26fc. This ports the fix to
dart2wasm.

This currently doesn't fix any tests as there are other issues with
dart2wasm's sync* implementation, which we are fixing in
https://dart-review.googlesource.com/c/sdk/+/366663.

Change-Id: I9d82d1bbb4c96ccb9bf411a385f4b7ff395a1c19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366671
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
Ömer Sinan Ağacan 2024-05-16 11:53:25 +00:00 committed by Commit Queue
parent 4ab652b38f
commit e7dde8377e

View File

@ -139,17 +139,22 @@ class _SyncStarIterator<T> implements Iterator<T> {
// Case: yield* some_iterator.
final iterable = _yieldStarIterable;
if (iterable != null) {
_yieldStarIterable = null;
_current = null;
if (iterable is _SyncStarIterable<T>) {
// We got a recursive yield* of sync* function. Instead of creating
// a new iterator we replace our current _state (remembering the
// current _state for later resumption).
_state = _SuspendState(iterable, _state).._iterator = this;
} else {
_yieldStarIterator = iterable.iterator;
try {
_yieldStarIterator = iterable.iterator;
} catch (exception, stackTrace) {
pendingException = exception;
pendingStackTrace = stackTrace;
}
}
_yieldStarIterable = null;
_current = null;
// Fetch the next item.
// Fetch the next item or continue with exception.
continue;
}