From b6ee9174c4365112c5798ba35d75348e4cd3d18e Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Fri, 17 Nov 2023 15:15:04 +0100 Subject: [PATCH 1/2] Proposed error for await e where the type of e is an extension type --- .../extension-types/feature-specification.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/accepted/future-releases/extension-types/feature-specification.md b/accepted/future-releases/extension-types/feature-specification.md index d85e665bf..0c46e3c31 100644 --- a/accepted/future-releases/extension-types/feature-specification.md +++ b/accepted/future-releases/extension-types/feature-specification.md @@ -15,6 +15,9 @@ 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 +2023.11.17 + - Correct the rule about extension types and `await` expressions. + 2023.10.31 - Simplify the rules about the relationship between extension types and the types `Object` and `Object?`. @@ -826,9 +829,18 @@ _is the extension type_ V\1, .. Ts>, and that its static type _is an extension type_. +We say that an extension type is _unrelated to `Future`_ in the case where +it does not implement `Future` for any `U` *(this means that it has no +direct or indirect superinterface of the form `Future<...>`)*. + 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` for any -`T`. +`e` satisfiers at least one of the following criteria: + +- an extension type which is unrelated to `Future`. +- a type of the form `E?`, `FutureOr`, or `FutureOr?` where `E` is an + extension type which is unrelated to `Future`. +- a type which is `T` bounded, where `T` matches one of the earlier items + *(this covers type variables and intersection types)*. 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 From e332cb71683000a0f28972a9423a9b3b8d052d94 Mon Sep 17 00:00:00 2001 From: Erik Ernst Date: Fri, 17 Nov 2023 15:23:17 +0100 Subject: [PATCH 2/2] Typo --- .../future-releases/extension-types/feature-specification.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/accepted/future-releases/extension-types/feature-specification.md b/accepted/future-releases/extension-types/feature-specification.md index 0c46e3c31..a4dfc1241 100644 --- a/accepted/future-releases/extension-types/feature-specification.md +++ b/accepted/future-releases/extension-types/feature-specification.md @@ -837,8 +837,8 @@ It is a compile-time error if `await e` occurs, and the static type of `e` satisfiers at least one of the following criteria: - an extension type which is unrelated to `Future`. -- a type of the form `E?`, `FutureOr`, or `FutureOr?` where `E` is an - extension type which is unrelated to `Future`. +- a type of the form `T?` or `FutureOr` where `T` is a type that matches + one of the items in this list. - a type which is `T` bounded, where `T` matches one of the earlier items *(this covers type variables and intersection types)*.