Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust the rule about await e where the type of e is an extension type #3560

Merged
merged 7 commits into from
Jan 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions accepted/future-releases/extension-types/feature-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ information about the process, including in their change logs.
[1]: https://github.com/dart-lang/language/blob/master/working/1426-extension-types/feature-specification-views.md
[2]: https://github.com/dart-lang/language/blob/master/working/extension_structs/overview.md

2024.01.17
- Specify that a type is 'incompatible with await', and use that to specify
a compile-time error at `await e;`.

2023.11.14
- Specify that a method declaration will shadow an otherwise "inherited"
setter with the same basename, and vice versa. This eliminates a
Expand Down Expand Up @@ -864,9 +868,20 @@ _is the extension type_
<code>V\<T<sub>1</sub>, .. T<sub>s</sub>&gt;</code>,
and that its static type _is an extension type_.

It is a compile-time error if `await e` occurs, and the static type of
`e` is an extension type which is not a subtype of `Future<T>` for any
`T`.
We say that a type `T` is _incompatible with await_ if at least
one of the following criteria holds:

- `T` is an extension type that does not implement `Future`.
- `T` is `S?`, and `S` is incompatible with await.
- `T` is `X & B`, and either:
- `B` is incompatible with await, or
- `B` does not derive a future type, and `X` is
incompatible with await.
- `T` is a type variable with bound `S`, and `S` is incompatible
with await.

Consider an expression of the form `await e`. A compile-time error
occurs if the static type of `e` is incompatible with await.

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