The PR dart-lang/language#3560 introduces the notion that a type can be incompatible with await. This concept is used to specify a new and broader error about expressions of the form await e where the static type of e has associations with an extension type that does not implement Future.
The previous rules just made it an error when the type was such an extension type, now it is also an error when it is T? where T is incompatible with await, or a type variable that extends such a type, etc. Details in dart-lang/language#3560. Example:
extension type N(Future<int> _) {}
extension type F(Future<int> _) implements Future<int> {}
void test<X, XN extends N, XF extends F>(
N n, F f, X x, XN xn, XF xf, N? nq, F? fq, XN? xnq, XF? xfq) async {
await n; // Error.
await f; // OK, type `int`.
await x; // OK, type `X`.
await xn; // Error.
await xf; // OK, type `int`.
await nq; // Error.
await fq; // OK, type `int?`.
await xnq; // Error.
await xfq; // OK, type `int?`.
if (x is N) await x; // Error.
if (x is N?) await x; // Error.
if (x is XN) await x; // Error.
if (x is XN?) await x; // Error.
if (x is F) await x; // OK, type `int`.
if (x is F?) await x; // OK, type `int?`.
if (x is XF) await x; // OK, type `int`.
if (x is XF?) await x; // OK, type `int?`.
}
Subtasks:
The PR dart-lang/language#3560 introduces the notion that a type can be incompatible with await. This concept is used to specify a new and broader error about expressions of the form
await ewhere the static type ofehas associations with an extension type that does not implementFuture.The previous rules just made it an error when the type was such an extension type, now it is also an error when it is
T?whereTis incompatible with await, or a type variable that extends such a type, etc. Details in dart-lang/language#3560. Example:Subtasks: