From d136a0ca8a65bfbe51875a942735b7230d7ebcd0 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Thu, 7 Nov 2024 11:34:02 +0200 Subject: [PATCH 1/6] #2559. Add extension types and enums to augmenting constructors test. Part 2. --- .../augmenting_constructors_A18_t01.dart | 15 +++++++++ .../augmenting_constructors_A18_t01_lib.dart | 23 ++++++++++++++ .../augmenting_constructors_A18_t02.dart | 15 +++++++++ .../augmenting_constructors_A18_t02_lib.dart | 23 ++++++++++++++ .../augmenting_constructors_A18_t04.dart | 15 ++++++++- .../augmenting_constructors_A18_t04_lib.dart | 17 ++++++++-- .../augmenting_constructors_A18_t05.dart | 16 ++++++++-- .../augmenting_constructors_A18_t05_lib.dart | 27 ++++++++++++++-- .../augmenting_constructors_A18_t06.dart | 5 +++ .../augmenting_constructors_A18_t06_lib.dart | 7 +++++ .../augmenting_constructors_A18_t07.dart | 14 +++++++++ .../augmenting_constructors_A18_t07_lib.dart | 31 +++++++++++++++++++ .../augmenting_constructors_A19_t01.dart | 9 ++++++ .../augmenting_constructors_A19_t01_lib.dart | 5 +++ .../augmenting_constructors_A19_t02.dart | 9 ++++++ .../augmenting_constructors_A19_t02_lib.dart | 5 +++ .../augmenting_constructors_A19_t03.dart | 9 ++++++ .../augmenting_constructors_A19_t03_lib.dart | 5 +++ .../augmenting_constructors_A20_t01.dart | 7 +++++ .../augmenting_constructors_A20_t01_lib.dart | 11 +++++++ .../augmenting_constructors_A20_t02.dart | 5 +++ .../augmenting_constructors_A20_t02_lib.dart | 8 +++++ .../augmenting_constructors_A20_t03.dart | 6 ++++ .../augmenting_constructors_A20_t03_lib.dart | 14 +++++++++ .../augmenting_constructors_A20_t04.dart | 8 +++++ .../augmenting_constructors_A20_t04_lib.dart | 11 +++++++ 26 files changed, 312 insertions(+), 8 deletions(-) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart index 398d4c3ac8..7915cb94f8 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart @@ -23,6 +23,21 @@ class C { C.bar({required this.y}); } +enum E { + e0(1, 2), e1.foo(3, y: 4), e2.bar(5, y: 6); + final int x, y; + const E(this.x, [this.y = 0]); + const E.foo(this.x, {this.y = 0}); + const E.bar(this.x, {required this.y}); +} + +extension type ET(int x) { + ET.foo(this.x); + ET.bar({required this.x}); +} + main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart index df2db60639..3fa904f564 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart @@ -26,3 +26,26 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment enum E { + augment e0; + augment const E.foo(this.x, {this.y}): this(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.bar(this.x, {required this.y}): this.foo(0); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment ET.foo(this.x): this(0); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.bar({required this.x}): this.new(1); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart index 8f78db3cfd..86faf08187 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart @@ -23,6 +23,21 @@ class C { C.bar({required int x}): x = x, y = 0; } +enum E { + e0(0); + final int x, y; + const E(this.x, [this.y = 0]); + const E.foo(int x, {int y = 0}): assert(x > 0); + const E.bar({required int x}): x = x, y = 0; +} + +extension type ET(int x) { + ET.foo(int x): assert(x > 0); + ET.bar({required int x}): x = x; +} + main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart index 584d4ba8aa..abc5dc925f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart @@ -26,3 +26,26 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment enum E { + augment e0; + augment const E.foo(int x, {int y = 0}): this(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.bar({required int x}): this.foo(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment ET.foo(int x): this(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.bar({required int x}): this.new(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart index 22ee766cb3..3135cdb6e4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart @@ -23,6 +23,19 @@ class C { C.foo(int x); } +enum E { + e0(0), e1.foo(1); + final int x; + const E(this.x); + const E.foo(int x); +} + +extension type ET(int x) { + ET.foo(int x); +} + main() { - Expect.equals(2, C.foo(1)); + Expect.equals(2, C.foo(1).x); + Expect.equals(2, E.e1.x); + Expect.equals(2, ET.foo(1).x); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart index f89cc1c50d..de046ba504 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart @@ -7,9 +7,9 @@ /// It is a compile-time error if: /// - The augmented constructor has any initializers or a body. /// -/// @description Checks that it is a compile-time error to declare an augmenting -/// redirecting generative constructor if the augmented constructor has a -/// non-empty initializing list. +/// @description Checks that it is not an error to declare an augmenting +/// redirecting generative constructor more than once and the fully merged +/// constructor has no errors. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -20,3 +20,14 @@ augment class C { augment C.foo(int x): this.foo(x); // Cyclic! But it is fixed below augment C.foo(int x): this(x + 1); // Not a cyclic now } + +augment enum E { + augment e0; + augment const E.foo(int x): this.foo(x); + augment const E.foo(int x): this(x + 1); +} + +augment extension type ET { + augment ET.foo(int x): this.foo(x); + augment ET.foo(int x): this(x + 1); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart index b77beffc20..c1aeae038c 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart @@ -7,8 +7,8 @@ /// It is a compile-time error if: /// - The augmented constructor has any initializers or a body. /// -/// @description Checks that it is a compile-time error if a merged constructor -/// is cyclic. +/// @description Checks that it is a compile-time error if the merged +/// constructor is cyclic. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -20,6 +20,18 @@ class C { C.foo(); } +enum E { + e0; + const E(); + const E.foo(); +} + +extension type ET(int x) { + ET.foo(this.x); +} + main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart index 0ceeec7e37..1c1472572e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart @@ -7,8 +7,8 @@ /// It is a compile-time error if: /// - The augmented constructor has any initializers or a body. /// -/// @description Checks that it is a compile-time error if a merged constructor -/// is cyclic. +/// @description Checks that it is a compile-time error if the merged +/// constructor is cyclic. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -25,3 +25,26 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment enum E { + augment e0; + augment const E(): this(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(): this.foo(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment ET(int x): this(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(int x): this.foo(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart index ade53e8a0a..9b5a257eb7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart @@ -20,6 +20,11 @@ class C { C.foo() {} } +extension type ET(int x) { + ET.foo(int x) {} +} + main() { print(C); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart index 36c30ebc20..f3b4a55ad6 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart @@ -21,3 +21,10 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + augment ET.foo(int x): this(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart index f0f7e37c7a..29dc5ea408 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart @@ -21,6 +21,20 @@ class C { C.bar(); } +enum E { + e0; + const E(); + const E.foo(); + const E.bar(); +} + +extension type ET(int x) { + ET.foo(int x); + ET.bar(int x); +} + main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart index acbd442083..946e0560c4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart @@ -29,3 +29,34 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment enum E { + augment e0; + augment const E(): this.foo(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(): this.bar(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.bar(): this(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment ET.new(int x): this.foo(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(int x): this.bar(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.bar(int x): this(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart index 5dfae14da1..8abf46b366 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart @@ -32,6 +32,12 @@ class D extends C { D(super.x, [super.y = 0]); } +extension type ET(int x) { + ET.foo(this.x); + factory ET.bar(int x); + factory ET.baz(int x); +} + main() { Expect.equals(1, C.bar(1).x); Expect.equals(0, C.bar(1).y); @@ -47,4 +53,7 @@ main() { Expect.equals(0, C.qux(1).y); Expect.equals(1, C.qux(1, 2).x); Expect.equals(2, C.qux(1, 2).y); + + Expect.equals(1, ET.bar(1).x); + Expect.equals(2, ET.baz(2).x); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart index 1beaa58cf6..0e57cacedc 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart @@ -23,3 +23,8 @@ augment class C { augment factory C.baz(int x, {int y}) = C.foo; augment factory C.qux(int x, [int y]) = D; } + +augment extension type ET { + augment factory ET.bar(int x) = ET; + augment factory ET.baz(int x) = ET.foo; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart index 452ae1eee5..99ac4500b1 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart @@ -32,6 +32,12 @@ class D extends C { D(super.x, [super.y = 0]); } +extension type ET(int x) { + ET.foo(this.x); + factory ET.bar(int x) = ET; + factory ET.baz(int x) = ET.foo; +} + main() { Expect.equals(1, C.bar(1).x); Expect.equals(0, C.bar(1).y); @@ -47,4 +53,7 @@ main() { Expect.equals(0, C.qux(1).y); Expect.equals(1, C.qux(1, 2).x); Expect.equals(2, C.qux(1, 2).y); + + Expect.equals(1, ET.bar(1).x); + Expect.equals(2, ET.baz(2).x); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart index a25c775366..f07b1a30eb 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart @@ -23,3 +23,8 @@ augment class C { augment factory C.baz(int x, {int y}) = C.foo; augment factory C.qux(int x, [int y]) = D; } + +augment extension type ET { + augment factory ET.bar(int x) = ET; + augment factory ET.baz(int x) = ET.foo; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart index 0bb18879f6..0cb598ebac 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart @@ -33,6 +33,12 @@ class D extends C { D.foo(int x, {int y = 1}): super(x, y); } +extension type ET(int x) { + ET.foo(this.x); + factory ET.bar(int x) = ET; + factory ET.baz(int x) = ET.foo; +} + main() { Expect.equals(1, C.bar(1).x); Expect.equals(1, C.bar(1).y); @@ -48,4 +54,7 @@ main() { Expect.equals(0, C.qux(1).y); Expect.equals(1, C.qux(1, 2).x); Expect.equals(2, C.qux(1, 2).y); + + Expect.equals(1, ET.bar(1).x); + Expect.equals(2, ET.baz(2).x); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart index 94b6feaa77..317711e20d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart @@ -23,3 +23,8 @@ augment class C { augment factory C.baz(int x, {int y}) = D.foo; augment factory C.qux(int x, [int y]) = C; } + +extension type ET { + augment factory ET.bar(int x) = ET.foo; + augment factory ET.baz(int x) = ET; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart index 70d1c64153..f5142a84c9 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart @@ -28,7 +28,14 @@ class D extends C { D(super.x, [super.y = 0]); } +extension type ET(int x) { + ET.foo(this.x); + factory ET.bar(int x) => ET(x); + factory ET.baz(int x) => ET.foo(x); +} + main() { print(C); print(D); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart index 1d572bc8c8..f7b1f97a10 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart @@ -29,3 +29,14 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + augment factory ET.bar(int x) = ET; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory ET.baz(int x) = ET.foo; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart index f88569c03a..2f35e0761d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart @@ -24,6 +24,11 @@ class C { factory C.qux({required int x}); } +extension type ET(int x) { + factory ET.foo(int x); +} + main() { print(C); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart index 20fbced2f3..8f9a314327 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart @@ -33,3 +33,11 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + + +augment extension type ET { + augment factory ET(int x) = ET.foo; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart index f645234cb3..76471d053a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart @@ -21,6 +21,12 @@ class C { factory C.bar(); } +extension type ET(int x) { + factory ET.foo(int x); + factory ET.bar(int x); +} + main() { print(C); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart index 287e7c5ef2..8e2a3aa44b 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart @@ -29,3 +29,17 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + augment factory ET(int x) = ET.bar; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory ET.foo(int x) = ET; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + // ^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart index 01b4bf85b2..8353b19541 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart @@ -24,6 +24,14 @@ class C { factory C.baz({int x = 0}); } +extension type ET(int x) { + ET.foo([this.x = 0]); + ET.bar({this.x = 0}); + factory ET.baz([int x = 0]); + factory ET.qux({int x = 0}); +} + main() { print(C); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart index 6e9e693ebf..a0469b3a32 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart @@ -26,3 +26,14 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + augment factory ET.baz([int x = 0]) = ET; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory ET.qux({int x = 0}) = ET.foo; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} From 41c629e6a729716749b3c983996277bc93ebb405 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Thu, 7 Nov 2024 11:37:01 +0200 Subject: [PATCH 2/6] Fix typos and make spec parser happy --- .../augmenting_constructors_A19_t03_lib.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart index 317711e20d..d4874c1b69 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart @@ -24,7 +24,7 @@ augment class C { augment factory C.qux(int x, [int y]) = C; } -extension type ET { +augment extension type ET { augment factory ET.bar(int x) = ET.foo; augment factory ET.baz(int x) = ET; } From 70a641565ddad90bc17cf01924023e6dc63ca444 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Fri, 15 Nov 2024 10:40:32 +0200 Subject: [PATCH 3/6] Update according to the changed spec --- .../augmenting_constructors_A06_t01.dart | 9 ++-- .../augmenting_constructors_A06_t01_lib.dart | 9 ++-- .../augmenting_constructors_A06_t02.dart | 33 ++++++++++++ .../augmenting_constructors_A06_t02_lib.dart | 21 ++++++++ .../augmenting_constructors_A17_t01.dart | 2 +- .../augmenting_constructors_A17_t01_lib.dart | 6 +-- .../augmenting_constructors_A17_t02.dart | 6 +-- .../augmenting_constructors_A17_t02_lib.dart | 4 +- .../augmenting_constructors_A18_t01.dart | 3 +- .../augmenting_constructors_A18_t01_lib.dart | 15 +++--- .../augmenting_constructors_A18_t02.dart | 16 +++--- .../augmenting_constructors_A18_t02_lib.dart | 27 +++++----- .../augmenting_constructors_A18_t03.dart | 7 +-- .../augmenting_constructors_A18_t03_lib.dart | 6 +-- .../augmenting_constructors_A18_t04.dart | 8 +-- .../augmenting_constructors_A18_t04_lib.dart | 29 +++++++---- .../augmenting_constructors_A18_t05.dart | 37 -------------- .../augmenting_constructors_A18_t05_lib.dart | 50 ------------------- .../augmenting_constructors_A18_t06.dart | 3 +- .../augmenting_constructors_A18_t06_lib.dart | 11 ++-- .../augmenting_constructors_A18_t07.dart | 3 +- .../augmenting_constructors_A18_t07_lib.dart | 3 +- .../augmenting_constructors_A19_t01.dart | 2 +- .../augmenting_constructors_A19_t01_lib.dart | 2 +- .../augmenting_constructors_A19_t02_lib.dart | 30 ----------- .../augmenting_constructors_A19_t03_lib.dart | 30 ----------- .../augmenting_constructors_A20_t01.dart | 2 +- .../augmenting_constructors_A20_t01_lib.dart | 2 +- .../augmenting_constructors_A20_t02.dart | 2 +- .../augmenting_constructors_A20_t02_lib.dart | 2 +- .../augmenting_constructors_A20_t03.dart | 2 +- .../augmenting_constructors_A20_t03_lib.dart | 2 +- .../augmenting_constructors_A20_t04.dart | 2 +- .../augmenting_constructors_A20_t04_lib.dart | 2 +- ...t => augmenting_constructors_A20_t05.dart} | 17 +++---- .../augmenting_constructors_A20_t05_lib.dart | 42 ++++++++++++++++ ...t => augmenting_constructors_A20_t06.dart} | 13 ++--- .../augmenting_constructors_A20_t06_lib.dart | 42 ++++++++++++++++ 38 files changed, 254 insertions(+), 248 deletions(-) create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart delete mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart rename LanguageFeatures/Augmentation-libraries/{augmenting_constructors_A19_t02.dart => augmenting_constructors_A20_t05.dart} (66%) create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05_lib.dart rename LanguageFeatures/Augmentation-libraries/{augmenting_constructors_A19_t03.dart => augmenting_constructors_A20_t06.dart} (75%) create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06_lib.dart diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart index a9b22d047f..e287f6c221 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart @@ -4,11 +4,12 @@ /// @assertion It is a compile-time error if: /// ... -/// - The resulting constructor is not valid (has a redirecting initializer and -/// other initializers, multiple super initializers, etc). +/// - The resulting constructor is not valid (it has a redirection as well as +/// some initializer list elements, or it has multiple super initializers, +/// etc). /// /// @description Checks that it is a compile-time error if the resulting -/// constructor has a redirecting initializer and other initializers. +/// constructor has a redirecting initializer and initializer list elements. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -18,7 +19,7 @@ part 'augmenting_constructors_A06_t01_lib.dart'; class C { int x; C(this.x); - C.foo(): this(0); + C.foo() : this(0); //^^^^^ // [analyzer] unspecified // [cfe] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart index d17f573d7a..69a638f86f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart @@ -4,11 +4,12 @@ /// @assertion It is a compile-time error if: /// ... -/// - The resulting constructor is not valid (has a redirecting initializer and -/// other initializers, multiple super initializers, etc). +/// - The resulting constructor is not valid (it has a redirection as well as +/// some initializer list elements, or it has multiple super initializers, +/// etc). /// /// @description Checks that it is a compile-time error if the resulting -/// constructor has a redirecting initializer and other initializers. +/// constructor has a redirecting initializer and initializer list elements. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -16,5 +17,5 @@ part of 'augmenting_constructors_A06_t01.dart'; augment class C { - augment C.foo(): x = 1; + augment C.foo() : x = 1; } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart new file mode 100644 index 0000000000..d668079313 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart @@ -0,0 +1,33 @@ +// 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 resulting constructor is not valid (it has a redirection as well as +/// some initializer list elements, or it has multiple super initializers, +/// etc). +/// +/// @description Checks that it is a compile-time error if the resulting +/// constructor has multiple super initializers. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part 'augmenting_constructors_A06_t02_lib.dart'; + +class A { + int x; + A(this.x); +} + +class C extends A { + C() : super(0); +//^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02_lib.dart new file mode 100644 index 0000000000..002827195f --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02_lib.dart @@ -0,0 +1,21 @@ +// 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 resulting constructor is not valid (it has a redirection as well as +/// some initializer list elements, or it has multiple super initializers, +/// etc). +/// +/// @description Checks that it is a compile-time error if the resulting +/// constructor has multiple super initializers. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A06_t02.dart'; + +augment class C { + augment C() : super(1); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart index 023d85df50..c7ba0a19f8 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A redirecting generative constructor marked `augment` adds its -/// redirecting initializer to the augmented constructors initializer list. +/// redirection to the augmented constructor. /// /// This converts it into a redirecting generative constructor, removing the /// potentially non-redirecting property of the constructor. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart index 27977c2286..1f02afc4d5 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A redirecting generative constructor marked `augment` adds its -/// redirecting initializer to the augmented constructors initializer list. +/// redirection to the augmented constructor. /// /// This converts it into a redirecting generative constructor, removing the /// potentially non-redirecting property of the constructor. @@ -18,6 +18,6 @@ part of 'augmenting_constructors_A17_t01.dart'; augment class C { - augment C.foo(int x, {int y}): this(x, y); - augment C.bar(int x, {required int y}): this.foo(x, y: y); + augment C.foo(int x, {int y}) : this(x, y); + augment C.bar(int x, {required int y}) : this.foo(x, y: y); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart index 7c6c91197d..b09aac0b31 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A redirecting generative constructor marked `augment` adds its -/// redirecting initializer to the augmented constructors initializer list. +/// redirection to the augmented constructor. /// /// This converts it into a redirecting generative constructor, removing the /// potentially non-redirecting property of the constructor. @@ -20,8 +20,8 @@ part 'augmenting_constructors_A17_t02_lib.dart'; class C { int x; C(this.x); - C.foo(int x): this(x + 1); - C.bar(int x): this(x + 1); + C.foo(int x) : this(x + 1); + C.bar(int x) : this(x + 1); } main() { diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart index 3953343e42..9610de404d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A redirecting generative constructor marked `augment` adds its -/// redirecting initializer to the augmented constructors initializer list. +/// redirection to the augmented constructor. /// /// This converts it into a redirecting generative constructor, removing the /// potentially non-redirecting property of the constructor. @@ -17,5 +17,5 @@ part of 'augmenting_constructors_A17_t02.dart'; augment class C { - augment C.bar(int x): this.foo(x + 1); + augment C.bar(int x) : this.foo(x + 1); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart index 7915cb94f8..eeff368f3e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if the augmented constructor has diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart index 3fa904f564..980f0e16f0 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t01_lib.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if the augmented constructor has @@ -17,11 +18,11 @@ part of 'augmenting_constructors_A18_t01.dart'; augment class C { - augment C.foo(this.x, {this.y}): this(x); + augment C.foo(this.x, {this.y}) : this(x); // ^ // [analyzer] unspecified // [cfe] unspecified - augment C.bar({required this.y}): this.foo(0); + augment C.bar({required this.y}) : this.foo(0); // ^ // [analyzer] unspecified // [cfe] unspecified @@ -29,22 +30,22 @@ augment class C { augment enum E { augment e0; - augment const E.foo(this.x, {this.y}): this(x); + augment const E.foo(this.x, {this.y}) : this(x); // ^ // [analyzer] unspecified // [cfe] unspecified - augment const E.bar(this.x, {required this.y}): this.foo(0); + augment const E.bar(this.x, {required this.y}) : this.foo(0); // ^ // [analyzer] unspecified // [cfe] unspecified } augment extension type ET { - augment ET.foo(this.x): this(0); + augment ET.foo(this.x) : this(0); // ^ // [analyzer] unspecified // [cfe] unspecified - augment ET.bar({required this.x}): this.new(1); + augment ET.bar({required this.x}) : this.new(1); // ^ // [analyzer] unspecified // [cfe] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart index 86faf08187..7a774349e7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if the augmented constructor has a @@ -19,21 +20,22 @@ part 'augmenting_constructors_A18_t02_lib.dart'; class C { int x, y; C(this.x, [this.y = 0]); - C.foo(int x, {int y = 0}): assert(x > 0); - C.bar({required int x}): x = x, y = 0; + C.foo(int x, {int y = 0}) : assert(x > 0); + C.bar({required int x}) : x = x, y = 0; } enum E { e0(0); + final int x, y; const E(this.x, [this.y = 0]); - const E.foo(int x, {int y = 0}): assert(x > 0); - const E.bar({required int x}): x = x, y = 0; + const E.foo(int x, {int y = 0}) : assert(x > 0); + const E.bar({required int x}) : x = x, y = 0; } extension type ET(int x) { - ET.foo(int x): assert(x > 0); - ET.bar({required int x}): x = x; + ET.foo(int x) : assert(x > 0); + ET.bar({required int x}) : x = x; } main() { diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart index abc5dc925f..38a3ad0d9a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t02_lib.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if the augmented constructor has a @@ -17,35 +18,35 @@ part of 'augmenting_constructors_A18_t02.dart'; augment class C { - augment C.foo(int x, {int y = 0}): this(x); -// ^ + augment C.foo(int x, {int y = 0}) : this(x); +// ^ // [analyzer] unspecified // [cfe] unspecified - augment C.bar({required int x}): this.foo(x); -// ^ + augment C.bar({required int x}) : this.foo(x); +// ^ // [analyzer] unspecified // [cfe] unspecified } augment enum E { augment e0; - augment const E.foo(int x, {int y = 0}): this(x); -// ^ + augment const E.foo(int x, {int y = 0}) : this(x); +// ^ // [analyzer] unspecified // [cfe] unspecified - augment const E.bar({required int x}): this.foo(x); -// ^ + augment const E.bar({required int x}) : this.foo(x); +// ^ // [analyzer] unspecified // [cfe] unspecified } augment extension type ET { - augment ET.foo(int x): this(x); -// ^ + augment ET.foo(int x) : this(x); +// ^ // [analyzer] unspecified // [cfe] unspecified - augment ET.bar({required int x}): this.new(x); -// ^ + augment ET.bar({required int x}) : this.new(x); +// ^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03.dart index f7298c6cc9..2d4bc6a473 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if the augmented constructor has a super @@ -22,8 +23,8 @@ class A { } class C extends A { - C(): super(0); - C.foo(): super(0); + C() : super(0); + C.foo() : super(0); } main() { diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart index 8022b47aa5..103338058c 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart @@ -5,11 +5,11 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting -/// redirecting generative constructor if the augmented constructor has a super -/// initializer. +/// redirecting generative constructor more than once. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart index 3135cdb6e4..0914abec74 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart @@ -5,11 +5,11 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// -/// @description Checks that it is not an error to declare an augmenting -/// redirecting generative constructor more than once and the fully merged -/// constructor has no errors. +/// @description Checks that it is a compile-time error to declare an augmenting +/// redirecting generative constructor more than once. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart index de046ba504..1e8f05866b 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04_lib.dart @@ -5,11 +5,11 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// -/// @description Checks that it is not an error to declare an augmenting -/// redirecting generative constructor more than once and the fully merged -/// constructor has no errors. +/// @description Checks that it is a compile-time error to declare an augmenting +/// redirecting generative constructor more than once. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -17,17 +17,26 @@ part of 'augmenting_constructors_A18_t04.dart'; augment class C { - augment C.foo(int x): this.foo(x); // Cyclic! But it is fixed below - augment C.foo(int x): this(x + 1); // Not a cyclic now + augment C.foo(int x) : this(x + 1); // Ok + augment C.foo(int x) : this(x + 2); // Augmented constructor already has a redirection +// ^ +// [analyzer] unspecified +// [cfe] unspecified } augment enum E { augment e0; - augment const E.foo(int x): this.foo(x); - augment const E.foo(int x): this(x + 1); + augment const E.foo(int x) : this(x + 1); + augment const E.foo(int x) : this(x + 2); +// ^ +// [analyzer] unspecified +// [cfe] unspecified } augment extension type ET { - augment ET.foo(int x): this.foo(x); - augment ET.foo(int x): this(x + 1); + augment ET.foo(int x) : this(x + 1); + augment ET.foo(int x) : this(x + 2); +// ^ +// [analyzer] unspecified +// [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart deleted file mode 100644 index c1aeae038c..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart +++ /dev/null @@ -1,37 +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 Redirecting generative constructors -/// ... -/// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. -/// -/// @description Checks that it is a compile-time error if the merged -/// constructor is cyclic. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A18_t05_lib.dart'; - -class C { - C(); - C.foo(); -} - -enum E { - e0; - const E(); - const E.foo(); -} - -extension type ET(int x) { - ET.foo(this.x); -} - -main() { - print(C); - print(E); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart deleted file mode 100644 index 1c1472572e..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_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 Redirecting generative constructors -/// ... -/// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. -/// -/// @description Checks that it is a compile-time error if the merged -/// constructor is cyclic. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A18_t05.dart'; - -augment class C { - augment C(): this(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo(): this.foo(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment enum E { - augment e0; - augment const E(): this(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment const E.foo(): this.foo(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment ET(int x): this(x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.foo(int x): this.foo(x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart index 9b5a257eb7..6a389ff304 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if an introductory constructor has a body diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart index f3b4a55ad6..07bf95f6b8 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t06_lib.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting generative constructor if an introductory constructor has a body @@ -16,15 +17,15 @@ part of 'augmenting_constructors_A18_t06.dart'; augment class C { - augment C.foo(): this(); -// ^ + augment C.foo() : this(); +// ^ // [analyzer] unspecified // [cfe] unspecified } augment extension type ET { - augment ET.foo(int x): this(x); -// ^ + augment ET.foo(int x) : this(x); +// ^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart index 29dc5ea408..d90f874a16 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error if a merged constructor /// is cyclic. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart index 946e0560c4..a17af1bfe3 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t07_lib.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has any initializers or a body. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error if a merged constructor /// is cyclic. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart index 8abf46b366..7701563efd 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A redirecting factory constructor marked `augment` adds its -/// factory redirection to the augmented constructor. +/// factory redirection (e.g., `= C.name`) to the augmented constructor. /// /// The result of applying the augmenting constructor is a redirecting factory /// constructor with the same target constructor designation as the augmenting diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart index 0e57cacedc..c3751cdf88 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t01_lib.dart @@ -3,7 +3,7 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A redirecting factory constructor marked `augment` adds its -/// factory redirection to the augmented constructor. +/// factory redirection (e.g., `= C.name`) to the augmented constructor. /// /// The result of applying the augmenting constructor is a redirecting factory /// constructor with the same target constructor designation as the augmenting diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart deleted file mode 100644 index f07b1a30eb..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02_lib.dart +++ /dev/null @@ -1,30 +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 A redirecting factory constructor marked `augment` adds its -/// factory redirection to the augmented constructor. -/// -/// The result of applying the augmenting constructor is a redirecting factory -/// constructor with the same target constructor designation as the augmenting -/// constructor. This removes the potentially non-redirecting property of the -/// constructor. -/// -/// @description Checks that it is not an error if an introductory constructor -/// already has a redirection. Test the same augmenting redirections. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A19_t02.dart'; - -augment class C { - augment factory C.bar(int x, [int y]) = C; - augment factory C.baz(int x, {int y}) = C.foo; - augment factory C.qux(int x, [int y]) = D; -} - -augment extension type ET { - augment factory ET.bar(int x) = ET; - augment factory ET.baz(int x) = ET.foo; -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart deleted file mode 100644 index d4874c1b69..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03_lib.dart +++ /dev/null @@ -1,30 +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 A redirecting factory constructor marked `augment` adds its -/// factory redirection to the augmented constructor. -/// -/// The result of applying the augmenting constructor is a redirecting factory -/// constructor with the same target constructor designation as the augmenting -/// constructor. This removes the potentially non-redirecting property of the -/// constructor. -/// -/// @description Checks that it is not an error if an introductory constructor -/// already has a redirection. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A19_t03.dart'; - -augment class C { - augment factory C.bar(int x, [int y]) = D; - augment factory C.baz(int x, {int y}) = D.foo; - augment factory C.qux(int x, [int y]) = C; -} - -augment extension type ET { - augment factory ET.bar(int x) = ET.foo; - augment factory ET.baz(int x) = ET; -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart index f5142a84c9..7a9bcd5b4e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error if the augmented /// constructor has a body. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart index f7b1f97a10..97daeff3ca 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t01_lib.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error if the augmented /// constructor has a body. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart index 2f35e0761d..3d99c2e37f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error if the augmenting /// constructor references itself. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart index 8f9a314327..e3bf108126 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t02_lib.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error if the augmenting /// constructor references itself. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart index 76471d053a..9ae964c527 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error if the augmenting /// constructor indirectly references itself. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart index 8e2a3aa44b..c13236e08f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t03_lib.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error if the augmenting /// constructor indirectly references itself. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart index 8353b19541..ea98832ab1 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting factory constructor if an introductory constructor has any diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart index a0469b3a32..99d60bdaf2 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t04_lib.dart @@ -5,7 +5,7 @@ /// @assertion Redirecting factory constructors /// ... /// It is a compile-time error if: -/// - The augmented constructor has a body. +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is a compile-time error to declare an augmenting /// redirecting factory constructor if an introductory constructor has any diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05.dart similarity index 66% rename from LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart rename to LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05.dart index 99ac4500b1..5b2115f971 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05.dart @@ -2,22 +2,19 @@ // 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 A redirecting factory constructor marked `augment` adds its -/// factory redirection to the augmented constructor. +/// @assertion Redirecting factory constructors +/// ... +/// It is a compile-time error if: +/// - The augmented factory constructor has a body, or it is redirecting. /// -/// The result of applying the augmenting constructor is a redirecting factory -/// constructor with the same target constructor designation as the augmenting -/// constructor. This removes the potentially non-redirecting property of the -/// constructor. -/// -/// @description Checks that it is not an error if an introductory constructor -/// already has a redirection. Test the same augmenting redirections. +/// @description Checks that it is a compile-time error if an introductory +/// constructor already has a redirection. Test the same augmenting redirections /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros import '../../Utils/expect.dart'; -part 'augmenting_constructors_A19_t02_lib.dart'; +part 'augmenting_constructors_A20_t05_lib.dart'; class C { int x, y; diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05_lib.dart new file mode 100644 index 0000000000..9234c91384 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t05_lib.dart @@ -0,0 +1,42 @@ +// 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 Redirecting factory constructors +/// ... +/// It is a compile-time error if: +/// - The augmented factory constructor has a body, or it is redirecting. +/// +/// @description Checks that it is a compile-time error if an introductory +/// constructor already has a redirection. Test the same augmenting redirections +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A20_t05.dart'; + +augment class C { + augment factory C.bar(int x, [int y]) = C; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory C.baz(int x, {int y}) = C.foo; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory C.qux(int x, [int y]) = D; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment factory ET.bar(int x) = ET; +// ^^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory ET.baz(int x) = ET.foo; +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06.dart similarity index 75% rename from LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart rename to LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06.dart index 0cb598ebac..795ed4e98f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A19_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06.dart @@ -2,13 +2,10 @@ // 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 A redirecting factory constructor marked `augment` adds its -/// factory redirection to the augmented constructor. -/// -/// The result of applying the augmenting constructor is a redirecting factory -/// constructor with the same target constructor designation as the augmenting -/// constructor. This removes the potentially non-redirecting property of the -/// constructor. +/// @assertion Redirecting factory constructors +/// ... +/// It is a compile-time error if: +/// - The augmented factory constructor has a body, or it is redirecting. /// /// @description Checks that it is not an error if an introductory constructor /// already has a redirection. @@ -17,7 +14,7 @@ // SharedOptions=--enable-experiment=macros import '../../Utils/expect.dart'; -part 'augmenting_constructors_A19_t03_lib.dart'; +part 'augmenting_constructors_A20_t06_lib.dart'; class C { int x, y; diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06_lib.dart new file mode 100644 index 0000000000..9738b40d1d --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A20_t06_lib.dart @@ -0,0 +1,42 @@ +// 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 Redirecting factory constructors +/// ... +/// It is a compile-time error if: +/// - The augmented factory constructor has a body, or it is redirecting. +/// +/// @description Checks that it is a compile-time error if an introductory +/// constructor already has a redirection. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A20_t06.dart'; + +augment class C { + augment factory C.bar(int x, [int y]) = D; +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory C.baz(int x, {int y}) = D.foo; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory C.qux(int x, [int y]) = C; +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment factory ET.bar(int x) = ET.foo; +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment factory ET.baz(int x) = ET; +// ^^ +// [analyzer] unspecified +// [cfe] unspecified +} From 943fddf587ac3c8bf672a6e45a25b0d8f7204ced Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 25 Nov 2024 12:18:38 +0200 Subject: [PATCH 4/6] Fix merge conflicts --- .../augmenting_constructors_A06_t01.dart | 2 +- .../augmenting_constructors_A06_t01_lib.dart | 2 +- .../augmenting_constructors_A09_t01.dart | 6 ++--- .../augmenting_constructors_A09_t01_lib.dart | 6 ++--- .../augmenting_constructors_A09_t02.dart | 2 -- .../augmenting_constructors_A09_t02_lib.dart | 2 -- .../augmenting_constructors_A09_t03.dart | 2 -- .../augmenting_constructors_A09_t03_lib.dart | 2 -- .../augmenting_constructors_A16_t01.dart | 1 + .../augmenting_constructors_A16_t01_lib.dart | 1 + .../augmenting_constructors_A16_t02.dart | 1 + .../augmenting_constructors_A16_t02_lib.dart | 1 + .../augmenting_constructors_A16_t03.dart | 1 + .../augmenting_constructors_A16_t03_lib.dart | 1 + .../augmenting_constructors_A16_t04.dart | 1 + .../augmenting_constructors_A16_t04_lib.dart | 1 + .../augmenting_constructors_A16_t05.dart | 1 + .../augmenting_constructors_A16_t05_lib.dart | 1 + .../augmenting_constructors_A18_t05.dart | 26 ++++++++++++++++++ .../augmenting_constructors_A18_t05_lib.dart | 27 +++++++++++++++++++ 20 files changed, 71 insertions(+), 16 deletions(-) create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart index e287f6c221..168b3b895b 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart @@ -5,7 +5,7 @@ /// @assertion It is a compile-time error if: /// ... /// - The resulting constructor is not valid (it has a redirection as well as -/// some initializer list elements, or it has multiple super initializers, +/// some initializer list elements, or it has multiple `super` initializers, /// etc). /// /// @description Checks that it is a compile-time error if the resulting diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart index 69a638f86f..4cc7346966 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart @@ -5,7 +5,7 @@ /// @assertion It is a compile-time error if: /// ... /// - The resulting constructor is not valid (it has a redirection as well as -/// some initializer list elements, or it has multiple super initializers, +/// some initializer list elements, or it has multiple `super` initializers, /// etc). /// /// @description Checks that it is a compile-time error if the resulting diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart index e6580b290a..94fc1977f7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart @@ -3,9 +3,9 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. +/// ... +/// - If the augmenting constructor has an explicit block body, then that body +/// replaces any existing constructor body. /// /// @description Checks that if the augmenting constructor has an explicit block /// body, then that body replaces any existing constructor body. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart index 2839810193..08a9eb7a45 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart @@ -3,9 +3,9 @@ // BSD-style license that can be found in the LICENSE file. /// @assertion A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. +/// ... +/// - If the augmenting constructor has an explicit block body, then that body +/// replaces any existing constructor body. /// /// @description Checks that if the augmenting constructor has an explicit block /// body, then that body replaces any existing constructor body. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart index 1a613b4dd4..ca82545ecb 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart @@ -4,8 +4,6 @@ /// @assertion A non-redirecting generative constructor marked `augment` may: /// - Add or replace the body of the augmented constructor with a new body. -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. /// /// @description Checks that an augmenting constructor may add a body to an /// augmented constructor. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart index f4f7e6019f..58d9b6c728 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart @@ -4,8 +4,6 @@ /// @assertion A non-redirecting generative constructor marked `augment` may: /// - Add or replace the body of the augmented constructor with a new body. -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. /// /// @description Checks that an augmenting constructor may add a body to an /// augmented constructor. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart index 4d588230c5..4b4b465ddd 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart @@ -4,8 +4,6 @@ /// @assertion A non-redirecting generative constructor marked `augment` may: /// - Add or replace the body of the augmented constructor with a new body. -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. /// /// @description Checks that it is a compile-time error to augment a default /// unnamed constructor (that doesn't exist during augmentation). diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03_lib.dart index 5854d9c541..3ed7718cb5 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03_lib.dart @@ -4,8 +4,6 @@ /// @assertion A non-redirecting generative constructor marked `augment` may: /// - Add or replace the body of the augmented constructor with a new body. -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. /// /// @description Checks that it is a compile-time error to augment a default /// unnamed constructor (that doesn't exist during augmentation). diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01.dart index ee541fbc3e..e9b9f87e62 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01_lib.dart index 16970539df..888477fe91 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t01_lib.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02.dart index 9ea4d30dd4..1cade00b99 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02_lib.dart index 9bc484d970..d47314d47a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t02_lib.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart index 09a7d42da8..c0ea8dc60a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart index 8322a9ff20..484026e854 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04.dart index 3a564a4df1..50df759f6c 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04_lib.dart index aaf9db9ef7..26d975b332 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t04_lib.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05.dart index 415168195a..5a3c7afc31 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05_lib.dart index 2319a0a66c..c661fba16a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t05_lib.dart @@ -4,6 +4,7 @@ /// @assertion A non-redirecting factory constructor marked `augment` works in /// the same way as a normal function augmentation. +/// /// If it has a body, it replaces the body of the augmented constructor /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart new file mode 100644 index 0000000000..1b95430595 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05.dart @@ -0,0 +1,26 @@ +// 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 Redirecting generative constructors +/// ... +/// It is a compile-time error if: +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. +/// +/// @description Checks that it is a compile-time error if a merged constructor +/// is cyclic. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part 'augmenting_constructors_A18_t05_lib.dart'; + +class C { + C(); + C.foo(); +} + +main() { + print(C); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart new file mode 100644 index 0000000000..f3faaf6720 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart @@ -0,0 +1,27 @@ +// 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 Redirecting generative constructors +/// ... +/// It is a compile-time error if: +/// - The augmented factory constructor has a body, or it is redirecting. +/// +/// @description Checks that it is a compile-time error if a merged constructor +/// is cyclic. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A18_t05.dart'; + +augment class C { + augment C(): this(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(): this.foo(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} From ea66108277e0f34a902e84be40e4430d5e97bec3 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 25 Nov 2024 14:05:14 +0200 Subject: [PATCH 5/6] Fix wrong assertion text in augmenting_constructors_A18_t05_lib.dart --- .../augmenting_constructors_A18_t05_lib.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart index f3faaf6720..11a3c10c6d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t05_lib.dart @@ -5,7 +5,8 @@ /// @assertion Redirecting generative constructors /// ... /// It is a compile-time error if: -/// - The augmented factory constructor has a body, or it is redirecting. +/// - The augmented constructor has an initializer list or a body, or it has a +/// redirection. /// /// @description Checks that it is a compile-time error if a merged constructor /// is cyclic. From ef4bcf19b96255f35a1bc265751f610f93a934df Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Mon, 25 Nov 2024 17:46:02 +0200 Subject: [PATCH 6/6] Implement review recommendations --- .../augmenting_constructors_A18_t03_lib.dart | 3 ++- .../augmenting_constructors_A18_t04.dart | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart index 103338058c..11ede4a7ef 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t03_lib.dart @@ -9,7 +9,8 @@ /// redirection. /// /// @description Checks that it is a compile-time error to declare an augmenting -/// redirecting generative constructor more than once. +/// redirecting generative constructor if the augmented constructor has a super +/// initializer. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart index 0914abec74..075424703a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A18_t04.dart @@ -14,7 +14,6 @@ // SharedOptions=--enable-experiment=macros -import '../../Utils/expect.dart'; part 'augmenting_constructors_A18_t04_lib.dart'; class C { @@ -35,7 +34,7 @@ extension type ET(int x) { } main() { - Expect.equals(2, C.foo(1).x); - Expect.equals(2, E.e1.x); - Expect.equals(2, ET.foo(1).x); + print(C); + print(E); + print(ET); }