From c7fbf4465e493eb24a184fe5dc9ac8ca5cbe3bce Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Thu, 1 Feb 2024 12:46:33 +0200 Subject: [PATCH 1/2] Fix #2490. Update incompatible with await tests according to the changed rule --- ...atic_analysis_extension_types_A08_t01.dart | 4 +-- ...atic_analysis_extension_types_A08_t02.dart | 4 +-- ...atic_analysis_extension_types_A08_t03.dart | 4 +-- ...atic_analysis_extension_types_A08_t04.dart | 4 +-- ...atic_analysis_extension_types_A08_t05.dart | 4 +-- ...atic_analysis_extension_types_A08_t06.dart | 4 +-- ...atic_analysis_extension_types_A08_t07.dart | 7 ++--- ...atic_analysis_extension_types_A08_t08.dart | 4 +-- ...atic_analysis_extension_types_A08_t09.dart | 4 +-- ...atic_analysis_extension_types_A08_t10.dart | 4 +-- ...atic_analysis_extension_types_A08_t11.dart | 4 +-- ...atic_analysis_extension_types_A08_t12.dart | 31 +++++++++++++++++++ 12 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t01.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t01.dart index f276522e55..bfe5a64675 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t01.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t01.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t02.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t02.dart index e93e75dd8d..83fbc8a575 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t02.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t02.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t03.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t03.dart index cc94c04abd..7b7dc2bbcb 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t03.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t03.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t04.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t04.dart index 60c573d4d3..97faf8f2f3 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t04.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t04.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t05.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t05.dart index ba18645fc9..2273e622df 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t05.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t05.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t06.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t06.dart index 21bc730702..66925165e6 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t06.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t06.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t07.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t07.dart index a8dc938ead..5b2fcd75eb 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t07.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t07.dart @@ -6,16 +6,13 @@ /// 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 X & B, and B 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. /// /// @description Checks that it is a compile-time error if `await e` occurs, and -/// the static type of `e` is `X & B` and `B` does not derive a future type, and -/// `X` is incompatible with await. +/// the static type of `e` is `X & B` and `B` is incompatible with await. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=inline-class diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t08.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t08.dart index 907019e25f..2510c4f0f6 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t08.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t08.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t09.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t09.dart index 7c2888f72d..92430ebf84 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t09.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t09.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t10.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t10.dart index d18442d4a2..3a26c70cc8 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t10.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t10.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t11.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t11.dart index f0bbc37be5..85813769ef 100644 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t11.dart +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t11.dart @@ -6,9 +6,7 @@ /// 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 X & B, and B 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. diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart new file mode 100644 index 0000000000..07eac6d5e8 --- /dev/null +++ b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion 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 B 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. +/// +/// @description Checks that it is not an error if `await e` occurs, and the +/// static type of `e` is `X & B` and `B` does not derive a future type but +/// compatible with await, and `X` is incompatible with await. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=inline-class + +extension type NumET(num _) implements num {} + +test(X x) async { + if (x is int) { + await x; + } +} + +main() { + test(NumET(42)); +} From d7b9ed916c19298a8424436a8bcfa58864a34567 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Fri, 2 Feb 2024 12:35:00 +0200 Subject: [PATCH 2/2] Remove wrong test --- ...atic_analysis_extension_types_A08_t12.dart | 31 ------------------- 1 file changed, 31 deletions(-) delete mode 100644 LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart diff --git a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart b/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart deleted file mode 100644 index 07eac6d5e8..0000000000 --- a/LanguageFeatures/Extension-types/static_analysis_extension_types_A08_t12.dart +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion 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 B 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. -/// -/// @description Checks that it is not an error if `await e` occurs, and the -/// static type of `e` is `X & B` and `B` does not derive a future type but -/// compatible with await, and `X` is incompatible with await. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=inline-class - -extension type NumET(num _) implements num {} - -test(X x) async { - if (x is int) { - await x; - } -} - -main() { - test(NumET(42)); -}