From 671b244716ea6a8f19ea545efebcc0a7da9b25a3 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 1 Dec 2025 18:04:35 +0200 Subject: [PATCH 1/2] #3182. Update `augmenting_functions_A02_*.dart` test --- .../augmenting_functions_A02_t01.dart | 102 +++++++-------- .../augmenting_functions_A02_t01_lib.dart | 46 ------- .../augmenting_functions_A02_t02.dart | 119 ++++++++++-------- .../augmenting_functions_A02_t02_lib.dart | 48 ------- .../augmenting_functions_A02_t03.dart | 119 ++++++++++-------- .../augmenting_functions_A02_t03_lib.dart | 48 ------- .../augmenting_functions_A02_t04.dart | 76 ----------- .../augmenting_functions_A02_t04_lib.dart | 50 -------- .../augmenting_functions_A02_t05.dart | 77 ------------ .../augmenting_functions_A02_t05_lib.dart | 49 -------- .../augmenting_functions_A02_t06.dart | 75 ----------- .../augmenting_functions_A02_t06_lib.dart | 49 -------- .../augmenting_functions_A02_t07.dart | 86 ------------- .../augmenting_functions_A02_t07_lib.dart | 54 -------- .../augmenting_functions_A02_t08.dart | 88 ------------- .../augmenting_functions_A02_t08_lib.dart | 54 -------- .../augmenting_functions_A02_t09.dart | 88 ------------- .../augmenting_functions_A02_t09_lib.dart | 56 --------- .../augmenting_functions_A02_t10.dart | 79 ------------ .../augmenting_functions_A02_t10_lib.dart | 49 -------- .../augmenting_functions_A02_t11.dart | 77 ------------ .../augmenting_functions_A02_t11_lib.dart | 49 -------- .../augmenting_functions_A02_t12.dart | 108 +++++++++------- .../augmenting_functions_A02_t12_lib.dart | 50 -------- 24 files changed, 245 insertions(+), 1451 deletions(-) delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t01_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t02_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t03_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t04.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t04_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t05.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t05_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t06.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t06_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t07.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t07_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t08.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t08_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t09.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t09_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t10.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t10_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t11.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t11_lib.dart delete mode 100644 LanguageFeatures/Augmentations/augmenting_functions_A02_t12_lib.dart diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart index 5926b7764e..3e2f688533 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart @@ -2,73 +2,65 @@ // 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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. +/// @assertion More precisely, a function or constructor declaration +/// (introductory or augmenting) is incomplete if all of: +/// - It has no body. That means no `{ ... }` or `=> ...;` but only `;`. +/// - The function is not marked external. An external function is considered to +/// have a body, just not one that is visible as Dart code. +/// - There is no redirection, initializer list, initializing formals, field +/// parameters, or super parameters. Obviously, this only applies to +/// constructor declarations. /// -/// @description Checks that inside an augmentation body of a top-level function -/// `augmented()` expression executes the original function body. +/// If a declaration is not incomplete then it is complete. +/// +/// It's a compile-time error if an augmentation is complete and any declaration +/// before it in the augmentation chain is also complete. +/// +/// @description Checks that it is a compile-time error to add a body to already +/// completed top level function. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t01_lib.dart'; +// SharedOptions=--enable-experiment=augmentations -String _log = ""; +void topLevelFunction1() {} -void clearLog() { - _log = ""; -} - -String topLevelFunction1() { - _log += "topLevelFunction1();"; - return "Original;"; -} +augment void topLevelFunction1() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified -String topLevelFunction2(String v) { - _log += "topLevelFunction2($v);"; - return "Original v=$v;"; -} +void topLevelFunction2(String v) {} -String topLevelFunction3(String v1, [String v2 = "v2 def"]) { - _log += "topLevelFunction3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; -} +augment void topLevelFunction2(String v) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified -String topLevelFunction4(String v1, {String v2 = "v2 def"}) { - _log += "topLevelFunction4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; -} +void topLevelFunction3(String v1, [String v2 = "v2 def"]) {} -String topLevelFunction5(String v1, {required String v2}) { - _log += "topLevelFunction5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; -} +augment void topLevelFunction3(String v1, [String v2 = "v2 def"]) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified -main() { - Expect.equals("augment;", topLevelFunction1()); - Expect.equals("topLevelFunction1();Original;augmented;", _log); - clearLog(); +void topLevelFunction4(String v1, {String v2 = "v2 def"}) {} - Expect.equals("augment v=A;", topLevelFunction2("A")); - Expect.equals("topLevelFunction2(A);Original v=A;augmented;", _log); - clearLog(); +augment void topLevelFunction4(String v1, {String v2 = "v2 def"}) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified - Expect.equals("augment v1=B, [v2=C]", topLevelFunction3("B", "C")); - Expect.equals("topLevelFunction3(B, [C]);Original v1=B, [v2=C];augmented;", - _log); - clearLog(); +void topLevelFunction5(String v1, {required String v2}) {} - Expect.equals("augment v1=D, {v2=E}", topLevelFunction4("D", v2: "E")); - Expect.equals("topLevelFunction4(D, {E});Original v1=D, {v2=E};augmented;", - _log); - clearLog(); +augment void topLevelFunction5(String v1, {required String v2}) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified - Expect.equals("augment v1=F, {required v2=G}", - topLevelFunction5("F", v2: "G")); - Expect.equals( - "topLevelFunction5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); +main() { + print(topLevelFunction1); + print(topLevelFunction2); + print(topLevelFunction3); + print(topLevelFunction4); + print(topLevelFunction5); } diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t01_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t01_lib.dart deleted file mode 100644 index e3f5e6b2c5..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t01_lib.dart +++ /dev/null @@ -1,46 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a top-level function -/// `augmented()` expression executes the original function body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t01.dart'; - -augment String topLevelFunction1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; -} - -augment String topLevelFunction2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; -} - -augment String topLevelFunction3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; -} - -augment String topLevelFunction4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; -} - -augment String topLevelFunction5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart index 70a735b831..7962297a90 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart @@ -2,72 +2,89 @@ // 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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. +/// @assertion More precisely, a function or constructor declaration +/// (introductory or augmenting) is incomplete if all of: +/// - It has no body. That means no `{ ... }` or `=> ...;` but only `;`. +/// - The function is not marked external. An external function is considered to +/// have a body, just not one that is visible as Dart code. +/// - There is no redirection, initializer list, initializing formals, field +/// parameters, or super parameters. Obviously, this only applies to +/// constructor declarations. /// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test a class. +/// If a declaration is not incomplete then it is complete. +/// +/// It's a compile-time error if an augmentation is complete and any declaration +/// before it in the augmentation chain is also complete. +/// +/// @description Checks that it is a compile-time error to add a body to already +/// completed static method. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t02_lib.dart'; +class C { + static void staticMethod() {} +} -String _log = ""; +augment class C { + augment static void staticMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} -void clearLog() { - _log = ""; +mixin M { + static void staticMethod() {} } -class C { - static String staticMethod1() { - _log += "staticMethod1();"; - return "Original;"; - } +augment mixin M { + augment static void staticMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - static String staticMethod2(String v) { - _log += "staticMethod2($v);"; - return "Original v=$v;"; - } +enum E { + e0; + static void staticMethod() {} +} - static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += "staticMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } +augment enum E { + ; + augment static void staticMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += "staticMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } +class A {} - static String staticMethod5(String v1, {required String v2}) { - _log += "staticMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } +extension Ext on A { + static void staticMethod() {} } -main() { - Expect.equals("augment;", C.staticMethod1()); - Expect.equals("staticMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", C.staticMethod2("A")); - Expect.equals("staticMethod2(A);Original v=A;augmented;", _log); - clearLog(); +augment extension Ext { + augment static void staticMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - Expect.equals("augment v1=B, [v2=C]", C.staticMethod3("B", "C")); - Expect.equals("staticMethod3(B, [C]);Original v1=B, [v2=C];augmented;", _log); - clearLog(); +extension type ET(int _) { + static void staticMethod() {} +} - Expect.equals("augment v1=D, {v2=E}", C.staticMethod4("D", v2: "E")); - Expect.equals("staticMethod4(D, {E});Original v1=D, {v2=E};augmented;", _log); - clearLog(); +augment extension type ET { + augment static void staticMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - Expect.equals("augment v1=F, {required v2=G}", C.staticMethod5("F", v2: "G")); - Expect.equals( - "staticMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); +main() { + print(C); + print(M); + print(E); + print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t02_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t02_lib.dart deleted file mode 100644 index 367624407b..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t02_lib.dart +++ /dev/null @@ -1,48 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test a class. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t02.dart'; - -augment class C { - augment static String staticMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment static String staticMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment static String staticMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart index d6aad37876..2aceeb2bb9 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart @@ -2,72 +2,89 @@ // 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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. +/// @assertion More precisely, a function or constructor declaration +/// (introductory or augmenting) is incomplete if all of: +/// - It has no body. That means no `{ ... }` or `=> ...;` but only `;`. +/// - The function is not marked external. An external function is considered to +/// have a body, just not one that is visible as Dart code. +/// - There is no redirection, initializer list, initializing formals, field +/// parameters, or super parameters. Obviously, this only applies to +/// constructor declarations. /// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test a mixin. +/// If a declaration is not incomplete then it is complete. +/// +/// It's a compile-time error if an augmentation is complete and any declaration +/// before it in the augmentation chain is also complete. +/// +/// @description Checks that it is a compile-time error to add a body to already +/// completed static method. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t03_lib.dart'; - -String _log = ""; +class C { + void instanceMethod() {} +} -void clearLog() { - _log = ""; +augment class C { + augment void instanceMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified } mixin M { - static String staticMethod1() { - _log += "staticMethod1();"; - return "Original;"; - } - - static String staticMethod2(String v) { - _log += "staticMethod2($v);"; - return "Original v=$v;"; - } + void instanceMethod() {} +} - static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += "staticMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } +augment mixin M { + augment void instanceMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += "staticMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } +enum E { + e0; + void instanceMethod() {} +} - static String staticMethod5(String v1, {required String v2}) { - _log += "staticMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } +augment enum E { + ; + static void instanceMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified } -main() { - Expect.equals("augment;", M.staticMethod1()); - Expect.equals("staticMethod1();Original;augmented;", _log); - clearLog(); +class A {} - Expect.equals("augment v=A;", M.staticMethod2("A")); - Expect.equals("staticMethod2(A);Original v=A;augmented;", _log); - clearLog(); +extension Ext on A { + void instanceMethod() {} +} - Expect.equals("augment v1=B, [v2=C]", M.staticMethod3("B", "C")); - Expect.equals("staticMethod3(B, [C]);Original v1=B, [v2=C];augmented;", _log); - clearLog(); +augment extension Ext { + augment void instanceMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - Expect.equals("augment v1=D, {v2=E}", M.staticMethod4("D", v2: "E")); - Expect.equals("staticMethod4(D, {E});Original v1=D, {v2=E};augmented;", _log); - clearLog(); +extension type ET(int _) { + static void instanceMethod() {} +} - Expect.equals("augment v1=F, {required v2=G}", M.staticMethod5("F", v2: "G")); - Expect.equals( - "staticMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); +augment extension type ET { + augment void instanceMethod() {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(M); + print(E); + print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t03_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t03_lib.dart deleted file mode 100644 index 4450ffdfbf..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t03_lib.dart +++ /dev/null @@ -1,48 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test a mixin. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t03.dart'; - -augment mixin M { - augment static String staticMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment static String staticMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment static String staticMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t04.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t04.dart deleted file mode 100644 index 01d96886e7..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t04.dart +++ /dev/null @@ -1,76 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test an enum. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t04_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -enum E { - e1; - - static String staticMethod1() { - _log += "staticMethod1();"; - return "Original;"; - } - - static String staticMethod2(String v) { - _log += "staticMethod2($v);"; - return "Original v=$v;"; - } - - static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += "staticMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += "staticMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - static String staticMethod5(String v1, {required String v2}) { - _log += "staticMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } -} - -main() { - Expect.equals("augment;", E.e1.staticMethod1()); - Expect.equals("staticMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", E.e1.staticMethod2("A")); - Expect.equals("staticMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", E.e1.staticMethod3("B", "C")); - Expect.equals("staticMethod3(B, [C]);Original v1=B, [v2=C];augmented;", _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", E.e1.staticMethod4("D", v2: "E")); - Expect.equals("staticMethod4(D, {E});Original v1=D, {v2=E};augmented;", _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - E.e1.staticMethod5("F", v2: "G")); - Expect.equals( - "staticMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t04_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t04_lib.dart deleted file mode 100644 index 85beb69542..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t04_lib.dart +++ /dev/null @@ -1,50 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test an enum. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t04.dart'; - -augment enum E { - augment e1; - - augment static String staticMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment static String staticMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment static String staticMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t05.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t05.dart deleted file mode 100644 index ebe7135553..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t05.dart +++ /dev/null @@ -1,77 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test an -/// extension. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t05_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -class A {} - -extension Ext on A { - static String staticMethod1() { - _log += "staticMethod1();"; - return "Original;"; - } - - static String staticMethod2(String v) { - _log += "staticMethod2($v);"; - return "Original v=$v;"; - } - - static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += "staticMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += "staticMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - static String staticMethod5(String v1, {required String v2}) { - _log += "staticMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } -} - -main() { - Expect.equals("augment;", Ext.staticMethod1()); - Expect.equals("staticMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", Ext.staticMethod2("A")); - Expect.equals("staticMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", Ext.staticMethod3("B", "C")); - Expect.equals("staticMethod3(B, [C]);Original v1=B, [v2=C];augmented;", _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", Ext.staticMethod4("D", v2: "E")); - Expect.equals("staticMethod4(D, {E});Original v1=D, {v2=E};augmented;", _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - Ext.staticMethod5("F", v2: "G")); - Expect.equals( - "staticMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t05_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t05_lib.dart deleted file mode 100644 index 548dd1e21f..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t05_lib.dart +++ /dev/null @@ -1,49 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test an -/// extension. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t05.dart'; - -augment extension Ext { - augment static String staticMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment static String staticMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment static String staticMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t06.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t06.dart deleted file mode 100644 index 3c4baa50da..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t06.dart +++ /dev/null @@ -1,75 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test an -/// extension type. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t06_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -extension type ET(int id) { - static String staticMethod1() { - _log += "staticMethod1();"; - return "Original;"; - } - - static String staticMethod2(String v) { - _log += "staticMethod2($v);"; - return "Original v=$v;"; - } - - static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += "staticMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += "staticMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - static String staticMethod5(String v1, {required String v2}) { - _log += "staticMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } -} - -main() { - Expect.equals("augment;", ET.staticMethod1()); - Expect.equals("staticMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", ET.staticMethod2("A")); - Expect.equals("staticMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", ET.staticMethod3("B", "C")); - Expect.equals("staticMethod3(B, [C]);Original v1=B, [v2=C];augmented;", _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", ET.staticMethod4("D", v2: "E")); - Expect.equals("staticMethod4(D, {E});Original v1=D, {v2=E};augmented;", _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - ET.staticMethod5("F", v2: "G")); - Expect.equals( - "staticMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t06_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t06_lib.dart deleted file mode 100644 index 373b811e31..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t06_lib.dart +++ /dev/null @@ -1,49 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of a static method -/// `augmented()` expression executes the original method body. Test an -/// extension type. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t06.dart'; - -augment extension type ET { - augment static String staticMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment static String staticMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment static String staticMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment static String staticMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment static String staticMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t07.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t07.dart deleted file mode 100644 index 37b23d98ba..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t07.dart +++ /dev/null @@ -1,86 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test a class. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t07_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -class C { - String instanceMethod1() { - _log += "instanceMethod1();"; - return "Original;"; - } - - String instanceMethod2(String v) { - _log += "instanceMethod2($v);"; - return "Original v=$v;"; - } - - String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += "instanceMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += "instanceMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - String instanceMethod5(String v1, {required String v2}) { - _log += "instanceMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } - - String instanceMethod6(covariant String v) { - _log += "instanceMethod6(covariant $v);"; - return "Original covariant v=$v"; - } -} - -main() { - Expect.equals("augment;", C().instanceMethod1()); - Expect.equals("instanceMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", C().instanceMethod2("A")); - Expect.equals("instanceMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", C().instanceMethod3("B", "C")); - Expect.equals("instanceMethod3(B, [C]);Original v1=B, [v2=C];augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", C().instanceMethod4("D", v2: "E")); - Expect.equals("instanceMethod4(D, {E});Original v1=D, {v2=E};augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - C().instanceMethod5("F", v2: "G")); - Expect.equals( - "instanceMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); - clearLog(); - - Expect.equals("augment covariant v=H", C().instanceMethod6("H")); - Expect.equals( - "instanceMethod6(covariant H);Original covariant v=H;augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t07_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t07_lib.dart deleted file mode 100644 index f6edcdce2a..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t07_lib.dart +++ /dev/null @@ -1,54 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test a class. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t07.dart'; - -augment class C { - augment String instanceMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment String instanceMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment String instanceMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } - - augment String instanceMethod6(covariant String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment covariant v=$v"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t08.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t08.dart deleted file mode 100644 index 13f339e33a..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t08.dart +++ /dev/null @@ -1,88 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test a mixin. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t08_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -mixin M { - String instanceMethod1() { - _log += "instanceMethod1();"; - return "Original;"; - } - - String instanceMethod2(String v) { - _log += "instanceMethod2($v);"; - return "Original v=$v;"; - } - - String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += "instanceMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += "instanceMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - String instanceMethod5(String v1, {required String v2}) { - _log += "instanceMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } - - String instanceMethod6(covariant String v) { - _log += "instanceMethod6(covariant $v);"; - return "Original covariant v=$v"; - } -} - -class MA = Object with M; - -main() { - Expect.equals("augment;", MA().instanceMethod1()); - Expect.equals("instanceMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", MA().instanceMethod2("A")); - Expect.equals("instanceMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", MA().instanceMethod3("B", "C")); - Expect.equals("instanceMethod3(B, [C]);Original v1=B, [v2=C];augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", MA().instanceMethod4("D", v2: "E")); - Expect.equals("instanceMethod4(D, {E});Original v1=D, {v2=E};augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - MA().instanceMethod5("F", v2: "G")); - Expect.equals( - "instanceMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); - clearLog(); - - Expect.equals("augment covariant v=H", MA().instanceMethod6("H")); - Expect.equals( - "instanceMethod6(covariant H);Original covariant v=H;augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t08_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t08_lib.dart deleted file mode 100644 index 6ca2d44d93..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t08_lib.dart +++ /dev/null @@ -1,54 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test a mixin. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t08.dart'; - -augment mixin M { - augment String instanceMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment String instanceMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment String instanceMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } - - augment String instanceMethod6(covariant String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment covariant v=$v"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t09.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t09.dart deleted file mode 100644 index c250238347..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t09.dart +++ /dev/null @@ -1,88 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test an enum. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t09_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -enum E { - e1; - - String instanceMethod1() { - _log += "instanceMethod1();"; - return "Original;"; - } - - String instanceMethod2(String v) { - _log += "instanceMethod2($v);"; - return "Original v=$v;"; - } - - String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += "instanceMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += "instanceMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - String instanceMethod5(String v1, {required String v2}) { - _log += "instanceMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } - - String instanceMethod6(covariant String v) { - _log += "instanceMethod6(covariant $v);"; - return "Original covariant v=$v"; - } -} - -main() { - Expect.equals("augment;", E.e1.instanceMethod1()); - Expect.equals("instanceMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", E.e1.instanceMethod2("A")); - Expect.equals("instanceMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", E.e1.instanceMethod3("B", "C")); - Expect.equals("instanceMethod3(B, [C]);Original v1=B, [v2=C];augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", E.e1.instanceMethod4("D", v2: "E")); - Expect.equals("instanceMethod4(D, {E});Original v1=D, {v2=E};augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - E.e1.instanceMethod5("F", v2: "G")); - Expect.equals( - "instanceMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); - clearLog(); - - Expect.equals("augment covariant v=H", E.e1.instanceMethod6("H")); - Expect.equals( - "instanceMethod6(covariant H);Original covariant v=H;augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t09_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t09_lib.dart deleted file mode 100644 index 9c2259779c..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t09_lib.dart +++ /dev/null @@ -1,56 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test an enum. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t09.dart'; - -augment enum E { - augment e1; - - augment String instanceMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment String instanceMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment String instanceMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } - - augment String instanceMethod6(covariant String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment covariant v=$v"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t10.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t10.dart deleted file mode 100644 index 69c5b4915c..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t10.dart +++ /dev/null @@ -1,79 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test an -/// extension. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t10_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -class A {} - -extension Ext on A { - String instanceMethod1() { - _log += "instanceMethod1();"; - return "Original;"; - } - - String instanceMethod2(String v) { - _log += "instanceMethod2($v);"; - return "Original v=$v;"; - } - - String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += "instanceMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += "instanceMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - String instanceMethod5(String v1, {required String v2}) { - _log += "instanceMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } -} - -main() { - Expect.equals("augment;", A().instanceMethod1()); - Expect.equals("instanceMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", A().instanceMethod2("A")); - Expect.equals("instanceMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", A().instanceMethod3("B", "C")); - Expect.equals("instanceMethod3(B, [C]);Original v1=B, [v2=C];augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", A().instanceMethod4("D", v2: "E")); - Expect.equals("instanceMethod4(D, {E});Original v1=D, {v2=E};augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - A().instanceMethod5("F", v2: "G")); - Expect.equals( - "instanceMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t10_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t10_lib.dart deleted file mode 100644 index 37578b2bf5..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t10_lib.dart +++ /dev/null @@ -1,49 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test an -/// extension. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t10.dart'; - -augment extension Ext { - augment String instanceMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment String instanceMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment String instanceMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t11.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t11.dart deleted file mode 100644 index ab5648b0f3..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t11.dart +++ /dev/null @@ -1,77 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test an -/// extension type. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t11_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} - -extension type ET(int id) { - String instanceMethod1() { - _log += "instanceMethod1();"; - return "Original;"; - } - - String instanceMethod2(String v) { - _log += "instanceMethod2($v);"; - return "Original v=$v;"; - } - - String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += "instanceMethod3($v1, [$v2]);"; - return "Original v1=$v1, [v2=$v2];"; - } - - String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += "instanceMethod4($v1, {$v2});"; - return "Original v1=$v1, {v2=$v2};"; - } - - String instanceMethod5(String v1, {required String v2}) { - _log += "instanceMethod5($v1, {required $v2});"; - return "Original v1=$v1, {required v2=$v2};"; - } -} - -main() { - Expect.equals("augment;", ET(0).instanceMethod1()); - Expect.equals("instanceMethod1();Original;augmented;", _log); - clearLog(); - - Expect.equals("augment v=A;", ET(0).instanceMethod2("A")); - Expect.equals("instanceMethod2(A);Original v=A;augmented;", _log); - clearLog(); - - Expect.equals("augment v1=B, [v2=C]", ET(0).instanceMethod3("B", "C")); - Expect.equals("instanceMethod3(B, [C]);Original v1=B, [v2=C];augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=D, {v2=E}", ET(0).instanceMethod4("D", v2: "E")); - Expect.equals("instanceMethod4(D, {E});Original v1=D, {v2=E};augmented;", - _log); - clearLog(); - - Expect.equals("augment v1=F, {required v2=G}", - ET(0).instanceMethod5("F", v2: "G")); - Expect.equals( - "instanceMethod5(F, {required G});Original v1=F, {required v2=G};" + - "augmented;", _log); -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t11_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t11_lib.dart deleted file mode 100644 index a86bca57e8..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t11_lib.dart +++ /dev/null @@ -1,49 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an instance method -/// `augmented()` expression executes the original method body. Test an -/// extension type. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t11.dart'; - -augment extension type ET { - augment String instanceMethod1() { - _log += augmented(); - _log += "augmented;"; - return "augment;"; - } - - augment String instanceMethod2(String v) { - _log += augmented(v); - _log += "augmented;"; - return "augment v=$v"; - } - - augment String instanceMethod3(String v1, [String v2 = "v2 def"]) { - _log += augmented(v1, v2); - _log += "augmented;"; - return "augment v1=$v1, [v2=$v2]"; - } - - augment String instanceMethod4(String v1, {String v2 = "v2 def"}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {v2=$v2}"; - } - - augment String instanceMethod5(String v1, {required String v2}) { - _log += augmented(v1, v2: v2); - _log += "augmented;"; - return "augment v1=$v1, {required v2=$v2}"; - } -} diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart index a4f9c70d76..53131cf41e 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart @@ -2,73 +2,89 @@ // 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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. +/// @assertion More precisely, a function or constructor declaration +/// (introductory or augmenting) is incomplete if all of: +/// - It has no body. That means no `{ ... }` or `=> ...;` but only `;`. +/// - The function is not marked external. An external function is considered to +/// have a body, just not one that is visible as Dart code. +/// - There is no redirection, initializer list, initializing formals, field +/// parameters, or super parameters. Obviously, this only applies to +/// constructor declarations. /// -/// @description Checks that inside an augmentation body of an operator -/// `augmented` expression executes the body of the original operator. +/// If a declaration is not incomplete then it is complete. +/// +/// It's a compile-time error if an augmentation is complete and any declaration +/// before it in the augmentation chain is also complete. +/// +/// @description Checks that it is a compile-time error to add a body to already +/// completed operator. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_functions_A02_t12_lib.dart'; - -String _log = ""; - -void clearLog() { - _log = ""; -} +// SharedOptions=--enable-experiment=augmentations class A {} class C { - String operator +(String other) { - _log += "C: original +($other);"; - return "C: original other=$other;"; - } + void operator +(String other) {} +} + +augment class C { + augment void operator +(String other) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified } mixin M { - String operator +(String other) { - _log += "M: original +($other);"; - return "M: original other=$other"; - } + void operator +(String other) {} +} + +augment mixin M { + augment void operator +(String other) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified } enum E { e1; + void operator +(String other) {} +} - String operator +(String other) { - _log += "E: original +($other);"; - return "E: original other=$other"; - } +augment enum E { + ; + augment void operator +(String other) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified } extension Ext on A { - String operator +(String other) { - _log += "Ext: original +($other);"; - return "Ext: original other=$other"; - } + void operator +(String other) {} } -class MA = Object with M; - -main() { - Expect.equals("C: augment other=A", C() + "A"); - Expect.equals("C: original +(A);C: original other=A;augmented;", _log); - clearLog(); +augment extension Ext { + augment void operator +(String other) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - Expect.equals("M: augment other=B", MA() + "B"); - Expect.equals("M: original +(B);M: original other=B;augmented;", _log); - clearLog(); +extension type ET(int _) { + void operator +(String other) {} +} - Expect.equals("E: augment other=C", E.e1 + "C"); - Expect.equals("E: original +(C);E: original other=C;augmented;", _log); - clearLog(); +augment extension type ET { + augment void operator +(String other) {} +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} - Expect.equals("Ext: augment other=D", A() + "D"); - Expect.equals("Ext: original +(D);Ext: original other=D;augmented;", _log); +main() { + print(C); + print(M); + print(E); + print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t12_lib.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t12_lib.dart deleted file mode 100644 index 7161974fc9..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t12_lib.dart +++ /dev/null @@ -1,50 +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 Inside the augmenting function’s body, a special `augmented(…)` -/// expression may be used to execute the augmented function body. That -/// expression takes an argument list matching the augmented function's -/// parameter list, and it has the same return type as the enclosing function. -/// -/// @description Checks that inside an augmentation body of an operator -/// `augmented` expression executes the body of the original operator. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_functions_A02_t12.dart'; - -augment class C { - augment String operator +(String other) { - _log += augmented + other; - _log += "augmented;"; - return "C: augment other=$other"; - } -} - -augment mixin M { - augment String operator +(String other) { - _log += augmented + other; - _log += "augmented;"; - return "M: augment other=$other"; - } -} - -augment enum E { - augment e1; - - augment String operator +(String other) { - _log += augmented + other; - _log += "augmented;"; - return "E: augment other=$other"; - } -} - -augment extension Ext { - augment String operator +(String other) { - _log += augmented + other; - _log += "augmented;"; - return "Ext: augment other=$other"; - } -} From 611653d0cf3232b13375dc208b744ac15a68fde3 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 2 Dec 2025 11:01:30 +0200 Subject: [PATCH 2/2] Fix typos. --- .../Augmentations/augmenting_functions_A02_t01.dart | 4 ++-- .../Augmentations/augmenting_functions_A02_t02.dart | 4 ++-- .../Augmentations/augmenting_functions_A02_t03.dart | 4 ++-- .../Augmentations/augmenting_functions_A02_t12.dart | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart index 3e2f688533..f8745fd832 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t01.dart @@ -16,8 +16,8 @@ /// It's a compile-time error if an augmentation is complete and any declaration /// before it in the augmentation chain is also complete. /// -/// @description Checks that it is a compile-time error to add a body to already -/// completed top level function. +/// @description Checks that it is a compile-time error to add a body to an +/// already complete top level function. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=augmentations diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart index 7962297a90..e4c700fd61 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t02.dart @@ -16,8 +16,8 @@ /// It's a compile-time error if an augmentation is complete and any declaration /// before it in the augmentation chain is also complete. /// -/// @description Checks that it is a compile-time error to add a body to already -/// completed static method. +/// @description Checks that it is a compile-time error to add a body to an +/// already complete static method. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=augmentations diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart index 2aceeb2bb9..19257faacd 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t03.dart @@ -16,8 +16,8 @@ /// It's a compile-time error if an augmentation is complete and any declaration /// before it in the augmentation chain is also complete. /// -/// @description Checks that it is a compile-time error to add a body to already -/// completed static method. +/// @description Checks that it is a compile-time error to add a body to an +/// already complete instance method. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=augmentations diff --git a/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart b/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart index 53131cf41e..4ee7abbf71 100644 --- a/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart +++ b/LanguageFeatures/Augmentations/augmenting_functions_A02_t12.dart @@ -16,8 +16,8 @@ /// It's a compile-time error if an augmentation is complete and any declaration /// before it in the augmentation chain is also complete. /// -/// @description Checks that it is a compile-time error to add a body to already -/// completed operator. +/// @description Checks that it is a compile-time error to add a body to an +/// already complete operator. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=augmentations