Skip to content

Commit c71b621

Browse files
authored
Adjust the rule about await e where the type of e is an extension type (#3560)
Adjust the rule about a compile-time error that may occur at `await e` when the type of e is an extension type. Previously the error only occurred when the static type of `e` was an extension type that does not implement `Future`. This PR introduces the concept of a type being _incompatible with await_ and specifies that this error occurs whenever the static type of `e` is incompatible with await. With this, the error occurs in several additional cases: When the static type of `e` is a type variable whose bound is such an extension type, or a nullable type whose operand is such an extension type, etc., recursively.
1 parent 205aa1f commit c71b621

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

accepted/future-releases/extension-types/feature-specification.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ information about the process, including in their change logs.
1515
[1]: https://github.com/dart-lang/language/blob/master/working/1426-extension-types/feature-specification-views.md
1616
[2]: https://github.com/dart-lang/language/blob/master/working/extension_structs/overview.md
1717

18+
2024.01.17
19+
- Specify that a type is 'incompatible with await', and use that to specify
20+
a compile-time error at `await e;`.
21+
1822
2023.11.14
1923
- Specify that a method declaration will shadow an otherwise "inherited"
2024
setter with the same basename, and vice versa. This eliminates a
@@ -864,9 +868,20 @@ _is the extension type_
864868
<code>V\<T<sub>1</sub>, .. T<sub>s</sub>&gt;</code>,
865869
and that its static type _is an extension type_.
866870

867-
It is a compile-time error if `await e` occurs, and the static type of
868-
`e` is an extension type which is not a subtype of `Future<T>` for any
869-
`T`.
871+
We say that a type `T` is _incompatible with await_ if at least
872+
one of the following criteria holds:
873+
874+
- `T` is an extension type that does not implement `Future`.
875+
- `T` is `S?`, and `S` is incompatible with await.
876+
- `T` is `X & B`, and either:
877+
- `B` is incompatible with await, or
878+
- `B` does not derive a future type, and `X` is
879+
incompatible with await.
880+
- `T` is a type variable with bound `S`, and `S` is incompatible
881+
with await.
882+
883+
Consider an expression of the form `await e`. A compile-time error
884+
occurs if the static type of `e` is incompatible with await.
870885

871886
A compile-time error occurs if an extension type declares a member whose
872887
basename is the basename of an instance member declared by `Object` as

0 commit comments

Comments
 (0)