From 84f2ed0f05113759fc64f19ac1b0c0788b37a638 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 11 Nov 2025 12:44:59 +0200 Subject: [PATCH 1/3] #2559. Update augmenting constructors tests --- .../augmenting_constructors_A01_t01.dart | 47 +++++++-- .../augmenting_constructors_A01_t01_lib.dart | 55 ----------- .../augmenting_constructors_A01_t02.dart | 81 +++++++++++++-- .../augmenting_constructors_A01_t02_lib.dart | 89 ----------------- .../augmenting_constructors_A01_t03.dart | 36 +++++-- .../augmenting_constructors_A01_t03_lib.dart | 44 --------- .../augmenting_constructors_A01_t04.dart | 85 +++++++++++++--- .../augmenting_constructors_A01_t04_lib.dart | 92 ----------------- .../augmenting_constructors_A01_t05.dart | 69 +++++++++++-- .../augmenting_constructors_A01_t05_lib.dart | 77 --------------- .../augmenting_constructors_A01_t07.dart | 48 +++++++-- .../augmenting_constructors_A01_t07_lib.dart | 52 ---------- .../augmenting_constructors_A01_t08.dart | 43 +++++--- .../augmenting_constructors_A01_t08_lib.dart | 40 -------- .../augmenting_constructors_A01_t09.dart | 22 +++-- .../augmenting_constructors_A01_t09_lib.dart | 31 ------ .../augmenting_constructors_A01_t10.dart | 81 +++++++++++---- .../augmenting_constructors_A01_t10_lib.dart | 73 -------------- .../augmenting_constructors_A01_t11.dart | 77 +++++++++++---- .../augmenting_constructors_A01_t11_lib.dart | 73 -------------- .../augmenting_constructors_A01_t12.dart | 83 ++++++++++++---- .../augmenting_constructors_A01_t12_lib.dart | 74 -------------- .../augmenting_constructors_A01_t13.dart | 98 ++++++++++++++----- .../augmenting_constructors_A01_t13_lib.dart | 85 ---------------- 24 files changed, 619 insertions(+), 936 deletions(-) delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13_lib.dart diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart index 480a78ea63..04b22fb6e3 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart @@ -3,34 +3,65 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is a compile-time error if the signature of the /// constructor augmentation does not match the original constructor. Test wrong /// number of positional parameters. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t01_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(int x); } +augment class C { + augment C(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment C(int x, int y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + enum E { e0(0); const E(int x); } +augment enum E { + augment e0; + augment const E(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment const E(int x, int y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int id) { ET.foo(this.id); } +augment extension type ET { + augment ET.foo(); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(int id, int y); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01_lib.dart deleted file mode 100644 index 35bccd6fe8..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01_lib.dart +++ /dev/null @@ -1,55 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if the signature of the -/// constructor augmentation does not match the original constructor.Test wrong -/// number of positional parameters. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t01.dart'; - -augment class C { - augment C(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - augment C(int x, int y); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; - augment const E(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - augment const E(int x, int y); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET.foo(): this.id = 0; -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.foo(this.id, int y); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart index b6cd197bed..2c3333a8cf 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart @@ -3,37 +3,102 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is a compile-time error if the signature of the /// constructor augmentation does not match the original constructor. Test wrong /// number of optional parameters. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t02_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C([int x = 0]); C.n({int x = 0}); } +augment class C { + augment C(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment C([int x, int y]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment class C { + augment C.n(); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augment C.n({int x, int y}); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + enum E { e0(0); const E([int x = 0]); const E.n({int x = 0}); } +augment enum E { + augment e0; + augment const E(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment const E([int x, int y]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment enum E { + augment e0; + augment const E.n(); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augment const E.n({int x, int y}); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int id) { ET.foo([int x = 0]): this.id = 0; ET.baz({int x = 0}): this.id = 0; } +augment extension type ET { + augment ET.foo(); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo([int x, int y = 0]); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augment ET.baz(); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.baz({int x, int y = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02_lib.dart deleted file mode 100644 index fd319deabd..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02_lib.dart +++ /dev/null @@ -1,89 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if the signature of the -/// constructor augmentation does not match the original constructor. Test wrong -/// number of optional parameters. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t02.dart'; - -augment class C { - augment C(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - augment C([int x, int y]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment class C { - augment C.n(); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - - augment C.n({int x, int y}); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; - augment const E(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - augment const E([int x, int y]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; - augment const E.n(); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - - augment const E.n({int x, int y}); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET.foo(); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.foo([int x, int y]); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - - augment ET.baz(); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.baz({int x, int y}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart index 6ba4fa7aae..374b839dee 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart @@ -3,25 +3,27 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is a compile-time error if the signature of the /// constructor augmentation does not match the original constructor. Test wrong /// names of named parameters. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t03_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C({int x = 0}); } +augment class C { + augment C({int y}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + enum E { e0; //^^ @@ -30,10 +32,28 @@ enum E { const E({int x = 0}); } +augment enum E { + augment e0; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E({int y}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int id) { ET.baz({int x = 0}): this.id = 0; } +augment extension type ET { + augment ET.baz({int y}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03_lib.dart deleted file mode 100644 index 76c58acca8..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03_lib.dart +++ /dev/null @@ -1,44 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if the signature of the -/// constructor augmentation does not match the original constructor. Test wrong -/// names of named parameters. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t03.dart'; - -augment class C { - augment C({int y}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E({int y}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET.baz({int y}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart index a2e651cae1..de57f0a3d3 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart @@ -3,40 +3,103 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is a compile-time error if the signature of the /// constructor augmentation does not match the original constructor. Test wrong /// type of parameters in an augmenting declaration. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t04_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(num x, [num y = 0]); C.foo(num x, {required num y, num z = 0}); } -enum E { - e0(0); -//^^ +augment class C { + augment C(int x, [num y]); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C(num x, [int y]); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(Object x, {required num y, num z}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(num x, {required Object y, num z}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(num x, {required num y, Object z}); +// ^^^^^^ // [analyzer] unspecified // [cfe] unspecified +} + +enum E { + e0(0), e1.foo(1); + const E(num x, [num y = 0]); const E.foo(num x, {required num y, num z = 0}); } +augment enum E { + augment const E(int x, [num y]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E(num x, [int y]); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(Object x, {required num y, num z}); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(num x, {required Object y, num z}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(num x, {required num y, Object z}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + + extension type ET(int id) { ET.foo(num x, [num y = 0]): this.id = 0; ET.baz(num x, {required num y, num z = 0}): this.id = 0; } +augment extension type ET { + augment ET.foo(int x, [num y = 0]); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(num x, [int y = 0]); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.baz(Object x, {required num y, num z = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.baz(num x, {required Object y, num z = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.baz(num x, {required num y, Object z = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04_lib.dart deleted file mode 100644 index 3342202ba5..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04_lib.dart +++ /dev/null @@ -1,92 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if the signature of the -/// constructor augmentation does not match the original constructor. Test wrong -/// type of parameters in an augmenting declaration. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t04.dart'; - -augment class C { - augment C(int x, [num y]); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment C(num x, [int y]); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo(Object x, {required num y, num z}); -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo(num x, {required Object y, num z}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo(num x, {required num y, Object z}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E(int x, [num y]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E(num x, [int y]); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.foo(Object x, {required num y, num z}); -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.foo(num x, {required Object y, num z}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.foo(num x, {required num y, Object z}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET.foo(int x, [num y = 0]); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.foo(num x, [int y = 0]); -// ^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.baz(Object x, {required num y, num z = 0}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.baz(num x, {required Object y, num z = 0}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.baz(num x, {required num y, Object z = 0}); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart index c1ba6e9b60..7039c04183 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart @@ -3,20 +3,15 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is a compile-time error if the signature of the /// constructor augmentation does not match the original constructor. Test wrong /// optionality of parameters in an augmenting declaration. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t05_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(int? x); @@ -25,6 +20,26 @@ class C { C.baz({required int? v}); } +augment class C { + augment C([int? x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(int? y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.bar({required int? z}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.baz({int? v}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + + enum E { e0(0); const E(int? x); @@ -33,6 +48,25 @@ enum E { const E.baz({required int? v}); } +augment enum E { + augment const E([int? x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(int? y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.bar({required int? z}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.baz({int? v}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int? id) { ET.foo(int? x): this.id = 0; ET.bar([int? y = 0]): this.id = 0; @@ -40,6 +74,25 @@ extension type ET(int? id) { ET.qux({required int? v}): this.id = 0; } +augment extension type ET { + augment ET.foo([int? x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.bar(int? y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.baz({required int? z}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.qux({int? v}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05_lib.dart deleted file mode 100644 index ae6d188df6..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05_lib.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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if the signature of the -/// constructor augmentation does not match the original constructor. Test wrong -/// optionality of parameters in an augmenting declaration. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t05.dart'; - -augment class C { - augment C([int? x]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo(int? y); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.bar({required int? z}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.baz({int? v}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; - augment const E([int? x]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.foo(int? y); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.bar({required int? z}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.baz({int? v}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET.foo([int? x]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.bar(int? y); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.baz({required int? z}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.qux({int? v}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart index a3baa094e0..f95442530d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart @@ -3,19 +3,14 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// -/// @description Checks that it is a compile-time error if initializing formals -/// of the constructor augmentation does not match the original constructor. +/// @description Checks that it is a compile-time error if parameter names of +/// the constructor augmentation does not match the original constructor. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t07_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { int x, y; @@ -23,6 +18,17 @@ class C { C.foo([this.x = 0, this.y = 0]); } +augment class C { + augment C(int y, int x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo([int y, int x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + enum E { e0(1, 2); final int x, y; @@ -30,11 +36,33 @@ enum E { const E.foo([this.x = 0, this.y = 0]); } +augment enum E { + augment const E(int y, int x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo([int y, int x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int x) { ET.foo(this.x, int y); ET.bar([this.x = 0, int y = 0]); } +augment extension type ET { + augment ET.foo(int y, int x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.bar([int y, int x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07_lib.dart deleted file mode 100644 index 46d1a37eb8..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07_lib.dart +++ /dev/null @@ -1,52 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if initializing formals -/// of the constructor augmentation does not match the original constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t07.dart'; - -augment class C { - augment C(this.y, this.x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo([this.y, this.x]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; - augment const E(this.y, this.x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.foo([this.y, this.x]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET.foo(int y, this.x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.bar([int y, this.x]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08.dart index 8c30f7179a..2805c0d39c 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08.dart @@ -3,19 +3,14 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// -/// @description Checks that it is a compile-time error if super parameters -/// of the constructor augmentation does not match the original constructor. +/// @description Checks that it is a compile-time error if parameter names of +/// the constructor augmentation does not match the original constructor. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A01_t08_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class A1 { A1(int x, int y); @@ -26,13 +21,35 @@ class C1 extends A1 { C1.foo([super.x = 1, super.y = 1]); } +augment class C1 { + augment C1(int y, int x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C1.foo([int y, int x]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + class A2 { - A2({int x = 0, int y = 0}); + A2({int x = 0}); } class C2 extends A2 { - C2({super.x = 1, super.y = 1}); - C2.foo({required super.x, required super.y}); + C2({super.x = 1}); + C2.foo({required super.x}); +} + +augment class C2 { + augment C2({int y}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C2.foo({int y}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified } main() { diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08_lib.dart deleted file mode 100644 index 25e182c7f1..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t08_lib.dart +++ /dev/null @@ -1,40 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is a compile-time error if super parameters -/// of the constructor augmentation does not match the original constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t08.dart'; - -augment class C1 { - augment C1(super.x, int y); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C1.foo([int x, super.y]); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment class C2 { - augment C2({super.x, int y}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C2.foo({int x, super.y}); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart index 1bc79ad19d..0c1a110f8e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart @@ -3,36 +3,44 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is not an error if a constructor augmentation /// reorders named parameters of the original constructor. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations import '../../Utils/expect.dart'; -part 'augmenting_constructors_A01_t09_lib.dart'; class C { int x, y; C({this.x = 0, this.y = 0}); } +augment class C { + augment C({int y, int x}); +} + enum E { e0(x: 1, y: 2); final int x, y; const E({this.x = 0, this.y = 0}); } +augment enum E { + augment const E({int y, int x}); +} + extension type ET(int x) { ET.foo({this.x = 0, int y = 0}); } +augment extension type ET { + augment ET.foo({int y, int x}); +} + main() { Expect.equals(1, C(x: 1, y: 2).x); Expect.equals(2, C(y: 2).y); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09_lib.dart deleted file mode 100644 index e6d9fb6d33..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09_lib.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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is not an error if a constructor augmentation -/// reorders named parameters of the original constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t09.dart'; - -augment class C { - augment C({this.y, this.x}); -} - -augment enum E { - augment e0; - augment const E({this.y, this.x}); -} - -augment extension type ET { - augment ET.foo({int y, this.x}); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart index dc54dd2fe0..4cc89b629a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart @@ -3,29 +3,45 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is not an error if a constructor augmentation /// omits types of formal parameters. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations import '../../Utils/expect.dart'; -part 'augmenting_constructors_A01_t10_lib.dart'; +import '../../Utils/static_type_helper.dart'; String _log = ""; class C { var x, y; - C(int this.x, [final int this.y = 0]); - C.foo({required int this.x, final int this.y = 0}); - C.bar(int x, [final int y = 0]): x = x, y = y; - C.baz({required int x, final int y = 0}): x = x, y = y; + C(int x, [final int y = 0]); + C.foo({required int x, final int y = 0}); + C.bar(int x, [final int y = 0]); + C.baz({required int x, final int y = 0}); +} + +augment class C { + augment C(this.x, [final this.y]) { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.foo({required this.x, final this.y}) { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.bar(x, [final y]) : x = x, y = y { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.baz({required x, final y}) : x = x, y = y { + x.expectStaticType>(); + y.expectStaticType>(); + } } enum E { @@ -37,26 +53,53 @@ enum E { const E.baz({required int x, final int y = 0}): x = x, y = y; } +augment enum E { + augment const E(x, [final y]); + augment const E.foo({required x, final y}); + augment const E.bar(x, [final y]); + augment const E.baz({required x, final y}); +} + + extension type ET(int x) { - ET.foo(int this.x, [final int y = 0]); - ET.bar({required int this.x, final int y = 0}); - ET.baz(int x, [final int y = 0]): x = x; - ET.qux({required int x, final int y = 0}): x = x; + ET.foo(int x, [final int y = 0]); + ET.bar({required int x, final int y = 0}); + ET.baz(int x, [final int y = 0]); + ET.qux({required int x, final int y = 0}); +} + +augment extension type ET { + augment ET.foo(this.x, [final y]) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.bar({required this.x, final y}) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.baz(x, [final y]) : x = x { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.qux({required x, final y}) : x = x { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } } main() { Expect.equals(1, C(1).x); Expect.equals(0, C(1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.foo(x: 1).x); Expect.equals(0, C.foo(x: 1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.bar(1).x); Expect.equals(0, C.bar(1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.baz(x: 1).x); Expect.equals(0, C.baz(x: 1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, E.e0.x); Expect.equals(0, E.e0.y); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10_lib.dart deleted file mode 100644 index 9b28c05241..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10_lib.dart +++ /dev/null @@ -1,73 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is not an error if a constructor augmentation -/// omits types of formal parameters. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t10.dart'; -import '../../Utils/static_type_helper.dart'; - -augment class C { - augment C(this.x, [final this.y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.foo({required this.x, final this.y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.bar(x, [final y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.baz({required x, final y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} - -augment enum E { - augment e0(1); - augment const E(this.x, [final this.y]); - augment const E.foo({required this.x, final this.y}); - augment const E.bar(x, [final y]); - augment const E.baz({required x, final y}); -} - -augment extension type ET { - augment ET.foo(this.x, [final y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.bar({required this.x, final y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.baz(x, [final y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.qux({required x, final y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart index 3bbf0a0e77..e35311cb34 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart @@ -3,29 +3,45 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is not an error if a constructor augmentation /// replaces type of formal parameter by `var`. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations import '../../Utils/expect.dart'; -part 'augmenting_constructors_A01_t11_lib.dart'; +import '../../Utils/static_type_helper.dart'; String _log = ""; class C { var x, y; - C(int this.x, [int this.y = 0]); - C.foo({required int this.x, int this.y = 0}); - C.bar(int x, [int y = 0]): x = x, y = y; - C.baz({required int x, int y = 0}): x = x, y = y; + C(int x, [int y = 0]); + C.foo({required int x, int y = 0}); + C.bar(int x, [int y = 0]); + C.baz({required int x, int y = 0}); +} + +augment class C { + augment C(var this.x, [var this.y]) { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.foo({required var this.x, var this.y}) { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.bar(var x, [var y]) : x = x, y = y{ + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.baz({required var x, var y}) : x = x, y = y { + x.expectStaticType>(); + y.expectStaticType>(); + } } enum E { @@ -37,26 +53,53 @@ enum E { const E.baz({required int x, int y = 0}): x = x, y = y; } +augment enum E { + augment e0(1); + augment const E(var this.x, [var this.y]); + augment const E.foo({required var this.x, var this.y}); + augment const E.bar(var x, [var y]); + augment const E.baz({required var x, var y}); +} + extension type ET(int x) { ET.foo(int this.x); ET.bar({required int this.x}); - ET.baz(int x, [int y = 0]): x = x; - ET.qux({required int x, int y = 0}): x = x; + ET.baz(int x, [int y = 0]); + ET.qux({required int x, int y = 0}); +} + +augment extension type ET { + augment ET.foo(var this.x, [var y]) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.bar({required var this.x, var y}) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.baz(var x, [var y]) : x = x { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.qux({required var x, var y}) : x = x { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } } main() { Expect.equals(1, C(1).x); Expect.equals(0, C(1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.foo(x: 1).x); Expect.equals(0, C.foo(x: 1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.bar(1).x); Expect.equals(0, C.bar(1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.baz(x: 1).x); Expect.equals(0, C.baz(x: 1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, E.e0.x); Expect.equals(0, E.e0.y); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11_lib.dart deleted file mode 100644 index 6bec26537f..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11_lib.dart +++ /dev/null @@ -1,73 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is not an error if a constructor augmentation -/// replaces type of formal parameter by `var`. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t11.dart'; -import '../../Utils/static_type_helper.dart'; - -augment class C { - augment C(var this.x, [var this.y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.foo({required var this.x, var this.y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.bar(var x, [var y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.baz({required var x, var y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} - -augment enum E { - augment e0(1); - augment const E(var this.x, [var this.y]); - augment const E.foo({required var this.x, var this.y}); - augment const E.bar(var x, [var y]); - augment const E.baz({required var x, var y}); -} - -augment extension type ET { - augment ET.foo(var this.x, [var y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.bar({required var this.x, var y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.baz(var x, [var y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.qux({required var x, var y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart index 91c821f3cf..c997305795 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart @@ -3,61 +3,104 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is not an error if a constructor augmentation /// specifies a type of formal parameter which were not explicitly specified in /// the introductory constructor. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations import '../../Utils/expect.dart'; -part 'augmenting_constructors_A01_t12_lib.dart'; +import '../../Utils/static_type_helper.dart'; String _log = ""; class C { int x, y; - C(this.x, [this.y = 0]); - C.foo({required this.x, this.y = 0}); - C.bar(x, [y = 0]): x = x, y = y; - C.baz({required x, y = 0}): x = x, y = y; + C(var x, [var y]); + C.foo({required x, var y}); + C.bar(x, [y]); + C.baz({required x, y}); +} + +augment class C { + augment C(int this.x, [int this.y = 0]) { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.foo({required int this.x, int this.y = 0}) { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.bar(int x, [int y = 0]) : x = x, y = y { + x.expectStaticType>(); + y.expectStaticType>(); + } + augment C.baz({required int x, int y = 0}) : x = x, y = y { + x.expectStaticType>(); + y.expectStaticType>(); + } } enum E { e0(1), e1.foo(x: 1), e2.bar(1), e3.baz(x: 1); final int x, y; - const E(this.x, [this.y = 0]); - const E.foo({required this.x, this.y = 0}); + const E(var x, [var y]); + const E.foo({required x, var y}); const E.bar(x, [y = 0]): x = x, y = y; - const E.baz({required x, y = 0}): x = x, y = y; + const E.baz({required x, y}); +} + +augment enum E { + augment e0(1); + augment const E(int this.x, [int this.y = 0]); + augment const E.foo({required int this.x, int this.y = 0}); + augment const E.bar(int x, [int y = 0]) : x = x, y = y; + augment const E.baz({required int x, int y = 0}) : x = x, y = y; } extension type ET(int x) { - ET.foo(this.x); - ET.bar({required this.x}); + ET.foo(var x); + ET.bar({required x}); ET.baz(x, [y = 0]): x = x; ET.qux({required x, y = 0}): x = x; } +augment extension type ET { + augment ET.foo(int this.x, [int y]) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.bar({required int this.x, int y}) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.baz(int x, [int y]) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } + augment ET.qux({required int x, int y}) { + x.expectStaticType>(); + y.expectStaticType>(); + _log = "Augmented: $x, $y"; + } +} + main() { Expect.equals(1, C(1).x); Expect.equals(0, C(1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.foo(x: 1).x); Expect.equals(0, C.foo(x: 1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.bar(1).x); Expect.equals(0, C.bar(1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, C.baz(x: 1).x); Expect.equals(0, C.baz(x: 1).y); - Expect.equals("Augmented: 1, 0", _log); Expect.equals(1, E.e0.x); Expect.equals(0, E.e0.y); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12_lib.dart deleted file mode 100644 index 527a6d8c89..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12_lib.dart +++ /dev/null @@ -1,74 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is not an error if a constructor augmentation -/// specifies a type of formal parameter which were not explicitly specified in -/// the introductory constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t12.dart'; -import '../../Utils/static_type_helper.dart'; - -augment class C { - augment C(int this.x, [int this.y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.foo({required int this.x, int this.y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.bar(int x, [int y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment C.baz({required int x, int y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} - -augment enum E { - augment e0(1); - augment const E(int this.x, [int this.y]); - augment const E.foo({required int this.x, int this.y}); - augment const E.bar(int x, [int y]); - augment const E.baz({required int x, int y}); -} - -augment extension type ET { - augment ET.foo(int this.x, [int y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.bar({required int this.x, int y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.baz(int x, [int y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.qux({required int x, int y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart index 4923aae7bc..ff7159bbc4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart @@ -3,61 +3,115 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. +/// - The signature of the augmenting function does not match the signature of +/// the augmented function. /// /// @description Checks that it is not an error if an introductory constructor /// parameters implicitly have type `dynamic` and the augmenting constructor /// specifies it explicitly. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros +// SharedOptions=--enable-experiment=augmentations import '../../Utils/expect.dart'; -part 'augmenting_constructors_A01_t13_lib.dart'; String _log = ""; class C { var x, y; - C(this.x, [this.y]); - C.foo({required this.x, this.y}); - C.bar(x, [y]): x = x, y = y; - C.baz({required x, y}): x = x, y = y; + C(var x, [var y]); + C.foo({required var x, var y}); + C.bar(x, [y]); + C.baz({required x, y}); +} + +augment class C { + augment C(dynamic this.x, [dynamic this.y]) { + if (1 > 2) { + x.checkDynamic; + y.checkDynamic; + } + } + augment C.foo({required dynamic this.x, dynamic this.y}) { + if (1 > 2) { + x.checkDynamic; + y.checkDynamic; + } + } + augment C.bar(dynamic x, [dynamic y]) : x = x, y = y { + if (1 > 2) { + x.checkDynamic; + y.checkDynamic; + } + } + augment C.baz({required dynamic x, dynamic y}) : x = x, y = y { + if (1 > 2) { + x.checkDynamic; + y.checkDynamic; + } + } } enum E { e0(1), e1.foo(x: 1), e2.bar(1), e3.baz(x: 1); final x, y; - const E(this.x, [this.y]); - const E.foo({required this.x, this.y}); - const E.bar(x, [y]): x = x, y = y; + const E(var x, [var y]); + const E.foo({required var x, var y}); + const E.bar(x, [y]); const E.baz({required x, y}): x = x, y = y; } +augment enum E { + augment e0(1); + augment const E(dynamic this.x, [dynamic this.y]); + augment const E.foo({required dynamic this.x, dynamic this.y}); + augment const E.bar(dynamic x, [dynamic y]) : x = x, y = y; + augment const E.baz({required dynamic x, dynamic y}) : x = x, y = y; +} + extension type ET(int x) { - ET.foo(this.x, y); - ET.bar(this.x, [y]); - ET.baz(this.x, {y}); - ET.qux(this.x, {required y}); + ET.foo(int x, y); + ET.bar(int x, [y]); + ET.baz(int x, {y}); + ET.qux(int x, {required y}); +} + +augment extension type ET { + augment ET.foo(this.x, dynamic y) { + if (1 > 2) { + y.checkDynamic; + } + _log = "Augmented: $x, $y"; + } + augment ET.bar(this.x, [dynamic y]) { + if (1 > 2) { + y.checkDynamic; + } + _log = "Augmented: $x, $y"; + } + augment ET.baz(this.x, {dynamic y}) { + if (1 > 2) { + y.checkDynamic; + } + _log = "Augmented: $x, $y"; + } + augment ET.qux(this.x, {required dynamic y}) { + if (1 > 2) { + y.checkDynamic; + } + _log = "Augmented: $x, $y"; + } } main() { Expect.equals(1, C(1).x); Expect.equals(null, C(1).y); - Expect.equals("Augmented: 1, null", _log); Expect.equals(1, C.foo(x: 1).x); Expect.equals(null, C.foo(x: 1).y); - Expect.equals("Augmented: 1, null", _log); Expect.equals(1, C.bar(1).x); Expect.equals(null, C.bar(1).y); - Expect.equals("Augmented: 1, null", _log); Expect.equals(1, C.baz(x: 1).x); Expect.equals(null, C.baz(x: 1).y); - Expect.equals("Augmented: 1, null", _log); Expect.equals(1, E.e0.x); Expect.equals(null, E.e0.y); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13_lib.dart deleted file mode 100644 index 7d1fed1e90..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13_lib.dart +++ /dev/null @@ -1,85 +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 It is a compile-time error if: -/// - The signature of the constructor augmentation does not match the original -/// constructor. It must have the same number of positional parameters, the -/// same named parameters, and matching parameters must have the same type, -/// optionality, and any required modifiers must match. Any initializing -/// formals and super parameters must also be the same in both constructors. -/// -/// @description Checks that it is not an error if an introductory constructor -/// parameters implicitly have type `dynamic` and the augmenting constructor -/// specifies it explicitly. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A01_t13.dart'; - -augment class C { - augment C(dynamic this.x, [dynamic this.y]) { - if (1 > 2) { - x.checkDynamic; - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } - augment C.foo({required dynamic this.x, dynamic this.y}) { - if (1 > 2) { - x.checkDynamic; - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } - augment C.bar(dynamic x, [dynamic y]) { - if (1 > 2) { - x.checkDynamic; - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } - augment C.baz({required dynamic x, dynamic y}) { - if (1 > 2) { - x.checkDynamic; - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } -} - -augment enum E { - augment e0(1); - augment const E(dynamic this.x, [dynamic this.y]); - augment const E.foo({required dynamic this.x, dynamic this.y}); - augment const E.bar(dynamic x, [dynamic y]); - augment const E.baz({required dynamic x, dynamic y}); -} - -augment extension type ET { - augment ET.foo(this.x, dynamic y) { - if (1 > 2) { - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } - augment ET.bar(this.x, [dynamic y]) { - if (1 > 2) { - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } - augment ET.baz(this.x, {dynamic y}) { - if (1 > 2) { - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } - augment ET.qux(this.x, {required dynamic y}) { - if (1 > 2) { - y.checkDynamic; - } - _log = "Augmented: $x, $y"; - } -} From 330cc6bfc886fb764725872e9c25485c3336967d Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 11 Nov 2025 13:04:19 +0200 Subject: [PATCH 2/3] Fix augmenting enums syntax --- .../augmenting_constructors_A01_t01.dart | 2 +- .../augmenting_constructors_A01_t02.dart | 2 +- .../augmenting_constructors_A01_t03.dart | 8 +------- .../augmenting_constructors_A01_t04.dart | 1 + .../augmenting_constructors_A01_t05.dart | 1 + .../augmenting_constructors_A01_t07.dart | 1 + .../augmenting_constructors_A01_t09.dart | 1 + .../augmenting_constructors_A01_t10.dart | 1 + .../augmenting_constructors_A01_t11.dart | 2 +- .../augmenting_constructors_A01_t12.dart | 2 +- .../augmenting_constructors_A01_t13.dart | 2 +- 11 files changed, 11 insertions(+), 12 deletions(-) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart index 04b22fb6e3..f325e99361 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t01.dart @@ -35,7 +35,7 @@ enum E { } augment enum E { - augment e0; + ; augment const E(); // ^ // [analyzer] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart index 2c3333a8cf..c159a9d761 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart @@ -49,7 +49,7 @@ enum E { } augment enum E { - augment e0; + ; augment const E(); // ^ // [analyzer] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart index 374b839dee..cf80b11dcb 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t03.dart @@ -26,17 +26,11 @@ augment class C { enum E { e0; -//^^ -// [analyzer] unspecified -// [cfe] unspecified const E({int x = 0}); } augment enum E { - augment e0; -// ^ -// [analyzer] unspecified -// [cfe] unspecified + ; augment const E({int y}); // ^ // [analyzer] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart index de57f0a3d3..9586a191db 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t04.dart @@ -49,6 +49,7 @@ enum E { } augment enum E { + ; augment const E(int x, [num y]); // ^ // [analyzer] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart index 7039c04183..0ba98fd512 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t05.dart @@ -49,6 +49,7 @@ enum E { } augment enum E { + ; augment const E([int? x]); // ^ // [analyzer] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart index f95442530d..4cb92806d3 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t07.dart @@ -37,6 +37,7 @@ enum E { } augment enum E { + ; augment const E(int y, int x); // ^ // [analyzer] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart index 0c1a110f8e..9da83f8454 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t09.dart @@ -30,6 +30,7 @@ enum E { } augment enum E { + ; augment const E({int y, int x}); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart index 4cc89b629a..203cb96a59 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart @@ -54,6 +54,7 @@ enum E { } augment enum E { + ; augment const E(x, [final y]); augment const E.foo({required x, final y}); augment const E.bar(x, [final y]); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart index e35311cb34..7791a67a0f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart @@ -54,7 +54,7 @@ enum E { } augment enum E { - augment e0(1); + ; augment const E(var this.x, [var this.y]); augment const E.foo({required var this.x, var this.y}); augment const E.bar(var x, [var y]); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart index c997305795..f58e115fd1 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart @@ -55,7 +55,7 @@ enum E { } augment enum E { - augment e0(1); + ; augment const E(int this.x, [int this.y = 0]); augment const E.foo({required int this.x, int this.y = 0}); augment const E.bar(int x, [int y = 0]) : x = x, y = y; diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart index ff7159bbc4..733145d051 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart @@ -62,7 +62,7 @@ enum E { } augment enum E { - augment e0(1); + ; augment const E(dynamic this.x, [dynamic this.y]); augment const E.foo({required dynamic this.x, dynamic this.y}); augment const E.bar(dynamic x, [dynamic y]) : x = x, y = y; From 570121b652db5ca20c5a94b4c46499fc0ee3c5f0 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Wed, 12 Nov 2025 14:16:10 +0200 Subject: [PATCH 3/3] Implement review recommendations --- .../augmenting_constructors_A01_t02.dart | 2 +- .../augmenting_constructors_A01_t10.dart | 48 +++--- .../augmenting_constructors_A01_t11.dart | 119 ------------- .../augmenting_constructors_A01_t12.dart | 160 ++++++++---------- .../augmenting_constructors_A01_t13.dart | 8 +- 5 files changed, 103 insertions(+), 234 deletions(-) delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart index c159a9d761..eddc9465c2 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t02.dart @@ -8,7 +8,7 @@ /// /// @description Checks that it is a compile-time error if the signature of the /// constructor augmentation does not match the original constructor. Test wrong -/// number of optional parameters. +/// number of optional positional parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=augmentations diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart index 203cb96a59..c6c490bb83 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t10.dart @@ -19,26 +19,26 @@ String _log = ""; class C { var x, y; - C(int x, [final int y = 0]); - C.foo({required int x, final int y = 0}); - C.bar(int x, [final int y = 0]); - C.baz({required int x, final int y = 0}); + C(int x, [int y = 0]); + C.foo({required int x, int y = 0}); + C.bar(int x, [int y = 0]); + C.baz({required int x, int y = 0}); } augment class C { - augment C(this.x, [final this.y]) { + augment C(this.x, [this.y]) { x.expectStaticType>(); y.expectStaticType>(); } - augment C.foo({required this.x, final this.y}) { + augment C.foo({required this.x, this.y}) { x.expectStaticType>(); y.expectStaticType>(); } - augment C.bar(x, [final y]) : x = x, y = y { + augment C.bar(x, [y]) : x = x, y = y { x.expectStaticType>(); y.expectStaticType>(); } - augment C.baz({required x, final y}) : x = x, y = y { + augment C.baz({required x, y}) : x = x, y = y { x.expectStaticType>(); y.expectStaticType>(); } @@ -47,45 +47,45 @@ augment class C { enum E { e0(1), e1.foo(x: 1), e2.bar(1), e3.baz(x: 1); final x, y; - const E(int this.x, [final int this.y = 0]); - const E.foo({required int this.x, final int this.y = 0}); - const E.bar(int x, [final int y = 0]): x = x, y = y; - const E.baz({required int x, final int y = 0}): x = x, y = y; + const E(int this.x, [int this.y = 0]); + const E.foo({required int this.x, int this.y = 0}); + const E.bar(int x, [int y = 0]): x = x, y = y; + const E.baz({required int x, int y = 0}): x = x, y = y; } augment enum E { ; - augment const E(x, [final y]); - augment const E.foo({required x, final y}); - augment const E.bar(x, [final y]); - augment const E.baz({required x, final y}); + augment const E(x, [y]); + augment const E.foo({required x, y}); + augment const E.bar(x, [y]); + augment const E.baz({required x, y}); } extension type ET(int x) { - ET.foo(int x, [final int y = 0]); - ET.bar({required int x, final int y = 0}); - ET.baz(int x, [final int y = 0]); - ET.qux({required int x, final int y = 0}); + ET.foo(int x, [int y = 0]); + ET.bar({required int x, int y = 0}); + ET.baz(int x, [int y = 0]); + ET.qux({required int x, int y = 0}); } augment extension type ET { - augment ET.foo(this.x, [final y]) { + augment ET.foo(this.x, [y]) { x.expectStaticType>(); y.expectStaticType>(); _log = "Augmented: $x, $y"; } - augment ET.bar({required this.x, final y}) { + augment ET.bar({required this.x, y}) { x.expectStaticType>(); y.expectStaticType>(); _log = "Augmented: $x, $y"; } - augment ET.baz(x, [final y]) : x = x { + augment ET.baz(x, [y]) : x = x { x.expectStaticType>(); y.expectStaticType>(); _log = "Augmented: $x, $y"; } - augment ET.qux({required x, final y}) : x = x { + augment ET.qux({required x, y}) : x = x { x.expectStaticType>(); y.expectStaticType>(); _log = "Augmented: $x, $y"; diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart deleted file mode 100644 index 7791a67a0f..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t11.dart +++ /dev/null @@ -1,119 +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 It is a compile-time error if: -/// - The signature of the augmenting function does not match the signature of -/// the augmented function. -/// -/// @description Checks that it is not an error if a constructor augmentation -/// replaces type of formal parameter by `var`. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=augmentations - -import '../../Utils/expect.dart'; -import '../../Utils/static_type_helper.dart'; - -String _log = ""; - -class C { - var x, y; - C(int x, [int y = 0]); - C.foo({required int x, int y = 0}); - C.bar(int x, [int y = 0]); - C.baz({required int x, int y = 0}); -} - -augment class C { - augment C(var this.x, [var this.y]) { - x.expectStaticType>(); - y.expectStaticType>(); - } - augment C.foo({required var this.x, var this.y}) { - x.expectStaticType>(); - y.expectStaticType>(); - } - augment C.bar(var x, [var y]) : x = x, y = y{ - x.expectStaticType>(); - y.expectStaticType>(); - } - augment C.baz({required var x, var y}) : x = x, y = y { - x.expectStaticType>(); - y.expectStaticType>(); - } -} - -enum E { - e0(1), e1.foo(x: 1), e2.bar(1), e3.baz(x: 1); - final x, y; - const E(int this.x, [int this.y = 0]); - const E.foo({required int this.x, int this.y = 0}); - const E.bar(int x, [int y = 0]): x = x, y = y; - const E.baz({required int x, int y = 0}): x = x, y = y; -} - -augment enum E { - ; - augment const E(var this.x, [var this.y]); - augment const E.foo({required var this.x, var this.y}); - augment const E.bar(var x, [var y]); - augment const E.baz({required var x, var y}); -} - -extension type ET(int x) { - ET.foo(int this.x); - ET.bar({required int this.x}); - ET.baz(int x, [int y = 0]); - ET.qux({required int x, int y = 0}); -} - -augment extension type ET { - augment ET.foo(var this.x, [var y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.bar({required var this.x, var y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.baz(var x, [var y]) : x = x { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.qux({required var x, var y}) : x = x { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} - -main() { - Expect.equals(1, C(1).x); - Expect.equals(0, C(1).y); - Expect.equals(1, C.foo(x: 1).x); - Expect.equals(0, C.foo(x: 1).y); - Expect.equals(1, C.bar(1).x); - Expect.equals(0, C.bar(1).y); - Expect.equals(1, C.baz(x: 1).x); - Expect.equals(0, C.baz(x: 1).y); - - Expect.equals(1, E.e0.x); - Expect.equals(0, E.e0.y); - Expect.equals(1, E.e1.x); - Expect.equals(0, E.e1.y); - Expect.equals(1, E.e2.x); - Expect.equals(0, E.e2.y); - Expect.equals(1, E.e3.x); - Expect.equals(0, E.e3.y); - - Expect.equals(1, ET.foo(1).x); - Expect.equals("Augmented: 1, 0", _log); - Expect.equals(1, ET.bar(x: 1).x); - Expect.equals("Augmented: 1, 0", _log); - Expect.equals(1, ET.baz(1)); - Expect.equals("Augmented: 1, 0", _log); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart index f58e115fd1..c3897b9f2b 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t12.dart @@ -6,115 +6,103 @@ /// - The signature of the augmenting function does not match the signature of /// the augmented function. /// -/// @description Checks that it is not an error if a constructor augmentation -/// specifies a type of formal parameter which were not explicitly specified in -/// the introductory constructor. +/// @description Checks that it is a compile-time error if a constructor +/// augmentation specifies a type of formal parameter which were not explicitly +/// specified in the introductory constructor and this type is not `dynamic`. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=augmentations -import '../../Utils/expect.dart'; -import '../../Utils/static_type_helper.dart'; - -String _log = ""; - class C { - int x, y; - C(var x, [var y]); - C.foo({required x, var y}); - C.bar(x, [y]); - C.baz({required x, y}); + int x; + C(x); + C.foo({x}); + C.bar([x]); + C.baz({required x}); } augment class C { - augment C(int this.x, [int this.y = 0]) { - x.expectStaticType>(); - y.expectStaticType>(); - } - augment C.foo({required int this.x, int this.y = 0}) { - x.expectStaticType>(); - y.expectStaticType>(); - } - augment C.bar(int x, [int y = 0]) : x = x, y = y { - x.expectStaticType>(); - y.expectStaticType>(); - } - augment C.baz({required int x, int y = 0}) : x = x, y = y { - x.expectStaticType>(); - y.expectStaticType>(); - } + augment C(int this.x); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augment C.foo({this.x = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augment C.bar([int x = 0]) : x = x; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augment C.baz({required int x}) : x = x; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified } enum E { e0(1), e1.foo(x: 1), e2.bar(1), e3.baz(x: 1); - final int x, y; - const E(var x, [var y]); - const E.foo({required x, var y}); - const E.bar(x, [y = 0]): x = x, y = y; - const E.baz({required x, y}); + final int x; + const E(x); + const E.foo({x}); + const E.bar([x]); + const E.baz({required x}); } augment enum E { ; - augment const E(int this.x, [int this.y = 0]); - augment const E.foo({required int this.x, int this.y = 0}); - augment const E.bar(int x, [int y = 0]) : x = x, y = y; - augment const E.baz({required int x, int y = 0}) : x = x, y = y; + augment const E(int this.x); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo({this.x = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.bar([int x = 0]) : x = x; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.baz({required int x}) : x = x; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified } extension type ET(int x) { - ET.foo(var x); - ET.bar({required x}); - ET.baz(x, [y = 0]): x = x; - ET.qux({required x, y = 0}): x = x; + ET.foo(x); + ET.bar({x}); + ET.baz([x]); + ET.qux({required x}); } augment extension type ET { - augment ET.foo(int this.x, [int y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.bar({required int this.x, int y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.baz(int x, [int y]) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } - augment ET.qux({required int x, int y}) { - x.expectStaticType>(); - y.expectStaticType>(); - _log = "Augmented: $x, $y"; - } -} + augment ET.foo(int this.x); +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified -main() { - Expect.equals(1, C(1).x); - Expect.equals(0, C(1).y); - Expect.equals(1, C.foo(x: 1).x); - Expect.equals(0, C.foo(x: 1).y); - Expect.equals(1, C.bar(1).x); - Expect.equals(0, C.bar(1).y); - Expect.equals(1, C.baz(x: 1).x); - Expect.equals(0, C.baz(x: 1).y); + augment ET.bar({this.x = 0}); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified - Expect.equals(1, E.e0.x); - Expect.equals(0, E.e0.y); - Expect.equals(1, E.e1.x); - Expect.equals(0, E.e1.y); - Expect.equals(1, E.e2.x); - Expect.equals(0, E.e2.y); - Expect.equals(1, E.e3.x); - Expect.equals(0, E.e3.y); + augment ET.baz([int x = 0]) : x = x; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified - Expect.equals(1, ET.foo(1).x); - Expect.equals("Augmented: 1, 0", _log); - Expect.equals(1, ET.bar(x: 1).x); - Expect.equals("Augmented: 1, 0", _log); - Expect.equals(1, ET.baz(1)); - Expect.equals("Augmented: 1, 0", _log); + augment ET.qux({required int x}) : x = x; +// ^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart index 733145d051..142a125ff6 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A01_t13.dart @@ -19,8 +19,8 @@ String _log = ""; class C { var x, y; - C(var x, [var y]); - C.foo({required var x, var y}); + C(x, [y]); + C.foo({required x, y}); C.bar(x, [y]); C.baz({required x, y}); } @@ -55,8 +55,8 @@ augment class C { enum E { e0(1), e1.foo(x: 1), e2.bar(1), e3.baz(x: 1); final x, y; - const E(var x, [var y]); - const E.foo({required var x, var y}); + const E(x, [y]); + const E.foo({required x, y}); const E.bar(x, [y]); const E.baz({required x, y}): x = x, y = y; }