This all worked previously, but there probably was a weird merge mistake
or something that deleted it.
Here the lost fixes are added again, with more testing.
Change-Id: I8941cb6c88c44e22b70c12c93f7256fb371177f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136976
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>