Commit Graph

15 Commits

Author SHA1 Message Date
Lasse R.H. Nielsen 478602ad79 Fix errors in Future implementation around Future<Future<X>>.
Previously, when completing a future with another future,
we always chained to the other future. This effectively awaits
the latter future and then completes the former with its result.
This is incorrect behavior if the former future is, say,
a `Future<Future<int>>` and the latter is a `Future<int>`.
In that case we *must not* await the latter future
because we can't complete the former future with an `int`.
We should just complete the future directly with the latter future
as a value.

We now check first whether to chain a `Future<T>` to another
future, and only does so if the latter future is a `Future<T>`
(or it's not a `T`, which shouldn't happen,
but currently does in some places).

Add test for behavior.

Change-Id: I57e27111c2fc7b7792dcf4ae9b7c1d5d504d0c0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/53602
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-12-14 16:34:28 +00:00
Lasse Reichstein Holst Nielsen 1003e91a35 Remove uses of, and need for, Expect.throwsNullCheckedError.
All code which was tested now throws a TypeError in both
sound and unsound null safe mode.

Change-Id: I304dfa6b8683223562f8613f3d14823fccab35bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170439
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-11-11 13:30:30 +00:00
Lasse R.H. Nielsen 02923c6f83 Make Future.wait not return a const <Never>[] when given no futures.
Fixes #43445.

Bug: https://github.com/dart-lang/sdk/issues/43445
Change-Id: I70f722f6bee1d4cfe4d53a5f37bc29f0751edd78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164162
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2020-09-25 10:37:00 +00:00
Robert Nystrom a1f87c6962 Reland "Fail synchronously if null is passed as an error to async APIs."
This is a reland of bef363bfb7

Original change's description:
> Fail synchronously if null is passed as an error to async APIs.
> 
> The first patchset is Lasse's original changes.
> 
> Change-Id: Ic5f24bcfc0ef4e82edee68d61e015b095cb5916e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138605
> Reviewed-by: Leaf Petersen <leafp@google.com>

Change-Id: I142831dca5dc4ca266ded08d93cb427ad3fbde74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139683
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-03-17 00:39:31 +00:00
David Morgan a5bf30c401 Revert "Fail synchronously if null is passed as an error to async APIs."
This reverts commit bef363bfb7.

Reason for revert: Breaks google3 tests, see b/151204525.

Original change's description:
> Fail synchronously if null is passed as an error to async APIs.
> 
> The first patchset is Lasse's original changes.
> 
> Change-Id: Ic5f24bcfc0ef4e82edee68d61e015b095cb5916e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138605
> Reviewed-by: Leaf Petersen <leafp@google.com>

TBR=leafp@google.com,rnystrom@google.com

Change-Id: Ie17c35e9d23c70a7aecd1ef292962154cf6f007d
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138925
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
2020-03-11 10:07:49 +00:00
Robert Nystrom bef363bfb7 Fail synchronously if null is passed as an error to async APIs.
The first patchset is Lasse's original changes.

Change-Id: Ic5f24bcfc0ef4e82edee68d61e015b095cb5916e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138605
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-03-10 23:42:43 +00:00
Dmitry Stefantsov ccb6ba948b [cfe] Gather constraints from both possibilities for FutureOr
Closes #37778.

Bug: http://dartbug.com/37778.
Change-Id: Ia8828c27ccc912831a0fea8a473c547184c99229
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115243
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2019-09-10 09:50:30 +00:00
Johnni Winther d153e98447 Revert "[cfe] Gather constraints from both possibilities for FutureOr"
This reverts commit 00e9561798.

Original change's description:
> [cfe] Gather constraints from both possibilities for FutureOr
> 
> Closes #37778.
> 
> Bug: http://dartbug.com/37778
> Change-Id: Ic06da9cf4e24e397e1f2a180b743190a4165dc3e
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113033
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

TBR=dmitryas@google.com,johnniwinther@google.com

Change-Id: I64677971c865180334958de13d2d82fec3daec85
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: http://dartbug.com/37778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113821
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-08-20 10:57:52 +00:00
Johnni Winther 00e9561798 [cfe] Gather constraints from both possibilities for FutureOr
Closes #37778.

Bug: http://dartbug.com/37778
Change-Id: Ic06da9cf4e24e397e1f2a180b743190a4165dc3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113033
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-08-20 08:43:22 +00:00
Lasse R.H. Nielsen 76db06cc24 Fix assert in Future code to allow a Future<Future<int>>.
Fix the `lib_2/async/future_test` test which was otherwise failing everywhere.
Updated status files.

Change-Id: I4e277dd7d47692b92b3303bfdd7cfbde120a8f87
Reviewed-on: https://dart-review.googlesource.com/65080
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2018-07-16 11:27:36 +00:00
Lasse R.H. Nielsen 0b58c4bd10 Change some constant declarations to lowerCase.
Retain the old values.

Reapply of https://dart-review.googlesource.com/c/sdk/+/20680 with fixes
for VM method fingerprints.

Change-Id: Ie14e7ccc3194d5561983348e6b6752728913ff4d
Reviewed-on: https://dart-review.googlesource.com/20664
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2017-11-14 12:59:14 +00:00
Lasse R.H. Nielsen e61fc07b58 Revert "Change some constant declarations to lowerCase."
This reverts commit c048cfb178.

Reason for revert: VM code fingerprints needs update.

Original change's description:
> Change some constant declarations to lowerCase.
> 
> Retain the old values.
> 
> Change-Id: I03bd326f379fe5f96d8f6081a7133de956d745c0
> Reviewed-on: https://dart-review.googlesource.com/11520
> Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
> Reviewed-by: Florian Loitsch <floitsch@google.com>

TBR=lrn@google.com,floitsch@google.com

Change-Id: I095e8198304ca4e59b39d30b0fdf0af4945e5231
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/20680
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2017-11-14 11:23:08 +00:00
Lasse R.H. Nielsen c048cfb178 Change some constant declarations to lowerCase.
Retain the old values.

Change-Id: I03bd326f379fe5f96d8f6081a7133de956d745c0
Reviewed-on: https://dart-review.googlesource.com/11520
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Florian Loitsch <floitsch@google.com>
2017-11-14 11:13:04 +00:00
Vyacheslav Egorov ab83ea939f Fix lib_2/async/future_test.dart multitest.
It was broken by migration in 42d354c91d.

BUG=
R=floitsch@google.com

Review-Url: https://codereview.chromium.org/3012433002 .
2017-08-28 13:34:52 +02:00
Ben Konyi 42d354c91d Migrated test block 168 to Dart 2.0.
This block felt trickier than others, mostly due to random errors that I
wasn't able to find a cause for. Tests that I'm uncertain about are:
-first_regression_test
-future_timeout_test
-future_or_bad_type_test/implements

These all have status entries to prevent failures, but I think these
tests need another set of eyes.

BUG=
R=rnystrom@google.com

Review-Url: https://codereview.chromium.org/2999943002 .
2017-08-21 00:59:34 -07:00