Skip to content

Commit 40fecd9

Browse files
Follow-up tweaks to await handling. (#3931)
This addresses comments from @lrhn that I didn't see before landing #3920.
1 parent 9cb7966 commit 40fecd9

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

resources/type-system/inference.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,22 +1057,23 @@ succintly, the syntax of Dart is extended to allow the following forms:
10571057
`T_1`. Since `T_1 <: FutureOr<flatten(T_1)>` for all `T_1`, it follows that
10581058
`v` must be an instance satisfying `FutureOr<flatten(T_1)>`, or
10591059
equivalently, satisfying `FutureOr<T>`. Therefore, `v` must either be an
1060-
instance satisfying either `Future<T>` or `T`. We consider the two cases
1061-
below._
1060+
instance satisfying `Future<T>`, or if not, it must be an instance
1061+
satisfying `T`. We consider the two cases below._
10621062

10631063
- If `v` is an instance satisfying type `Future<T>`, then let
10641064
`@AWAIT_WITH_TYPE_CHECK(m_1)` evaluate to `v`.
10651065

10661066
- Otherwise, let `@AWAIT_WITH_TYPE_CHECK(m_1)` evaluate to a future satisfying
10671067
type `Future<T>` that will complete to the value `v` at some later
10681068
point. _Such a future could, for instance, be created by executing
1069-
`Future<T>.value(v)` (this is sound because in this case `v` is an instance
1070-
satisfying `T`). It also could be created using a more efficient
1069+
`Future<T>.value(v)`, which is sound because in this case `v` is an instance
1070+
satisfying `T`. It also could be created using a more efficient
10711071
implementation-specific mechanism._
10721072

1073-
- _Note that these two cases in the abstract correspond concretely to a type
1074-
check in the implementation; this where the name `@AWAIT_WITH_TYPE_CHECK`
1075-
comes from._
1073+
_Note that the two cases here may imply a runtime implementation doing an
1074+
actual `is Future<T>` type check and branching on the result, or a compiler
1075+
may be able to optimize away the check in some cases. This where the name
1076+
`@AWAIT_WITH_TYPE_CHECK` comes from._
10761077

10771078
- `@CONCAT(m_1, m_2, ..., m_n)`, where each `m_i` is an elaborated expression
10781079
whose static type is a subtype of `String`, represents the operation of

0 commit comments

Comments
 (0)