diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart index 94fc1977f7..be31a4c38f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01.dart @@ -2,13 +2,14 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// ... -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). /// /// @description Checks that if the augmenting constructor has an explicit block -/// body, then that body replaces any existing constructor body. +/// body, then that body is executed after the body of the introductory +/// constructor. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -16,42 +17,46 @@ import '../../Utils/expect.dart'; part 'augmenting_constructors_A09_t01_lib.dart'; -String _log = ""; +String log = ""; class C1 { C1() { - _log += "Original"; + log += "Original;"; } } class C2 { C2() { - _log += "Original"; + log += "Original;"; } } class C3 { C3.new() { - _log += "Original"; + log += "Original;"; } } extension type ET(int id) { ET.foo(this.id) { - _log += "Original"; + log += "Original;"; } } +void checkLog(String expected) { + Expect.equals(expected, log); + log = ""; +} + main() { C1(); - Expect.equals("Augmented", _log); - _log = ""; + checkLog("Original;Augmented"); C2(); - Expect.equals("Augmented", _log); - _log = ""; + checkLog("Original;Augmented"); C3(); - Expect.equals("Augmented", _log); - _log = ""; + checkLog("Original;Augmented"); ET(0); - Expect.equals("Augmented", _log); + checkLog("Augmented"); + ET.foo(0); + checkLog("Original;Augmented"); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart index 08a9eb7a45..c7201bad3d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t01_lib.dart @@ -2,13 +2,14 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// ... -/// - If the augmenting constructor has an explicit block body, then that body -/// replaces any existing constructor body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). /// /// @description Checks that if the augmenting constructor has an explicit block -/// body, then that body replaces any existing constructor body. +/// body, then that body is executed after the body of the introductory +/// constructor. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -17,24 +18,27 @@ part of 'augmenting_constructors_A09_t01.dart'; augment class C1 { augment C1() { - _log += "Augmented"; + log += "Augmented"; } } augment class C2 { augment C2.new() { - _log += "Augmented"; + log += "Augmented"; } } augment class C3 { augment C3() { - _log += "Augmented"; + log += "Augmented"; } } augment extension type ET { + augment ET(int id) { + log += "Augmented"; + } augment ET.foo(this.id) { - _log += "Augmented"; + log += "Augmented"; } } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart index ca82545ecb..93a8b49cb8 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02.dart @@ -2,8 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). /// /// @description Checks that an augmenting constructor may add a body to an /// augmented constructor. @@ -14,7 +16,7 @@ import '../../Utils/expect.dart'; part 'augmenting_constructors_A09_t02_lib.dart'; -String _log = ""; +String log = ""; class C1 { C1(); @@ -32,16 +34,20 @@ extension type ET(int id) { ET.foo(this.id); } +void checkLog(String expected) { + Expect.equals(expected, log); + log = ""; +} + main() { C1(); - Expect.equals("Augmented", _log); - _log = ""; + checkLog("Augmented"); C2(); - Expect.equals("Augmented", _log); - _log = ""; + checkLog("Augmented"); C3(); - Expect.equals("Augmented", _log); - _log = ""; + checkLog("Augmented"); ET(0); - Expect.equals("Augmented", _log); + checkLog("Augmented"); + ET.foo(0); + checkLog("Augmented"); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart index 58d9b6c728..47e6a340a7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t02_lib.dart @@ -2,8 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). /// /// @description Checks that an augmenting constructor may add a body to an /// augmented constructor. @@ -15,24 +17,27 @@ part of 'augmenting_constructors_A09_t02.dart'; augment class C1 { augment C1() { - _log += "Augmented"; + log += "Augmented"; } } augment class C2 { augment C2.new() { - _log += "Augmented"; + log += "Augmented"; } } augment class C3 { augment C3() { - _log += "Augmented"; + log += "Augmented"; } } augment extension type ET { + augment ET.new(int id) { + log += "Augmented"; + } augment ET.foo(this.id) { - _log += "Augmented"; + log += "Augmented"; } } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart index 4b4b465ddd..488c4318c1 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03.dart @@ -2,8 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). /// /// @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 3ed7718cb5..a595959c43 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t03_lib.dart @@ -2,8 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). /// /// @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_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t04.dart new file mode 100644 index 0000000000..2e90715fde --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t04.dart @@ -0,0 +1,64 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that it is not an error if an augmenting constructor has +/// no body. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import '../../Utils/expect.dart'; + +class C { + int v; + C() : v = 0; + C.id(this.v) { + v++; + } +} + +augment class C { + augment C(); + augment C.id(this.v); +} + +enum E { + e0, e1.id(); + const E(); + const E.id(); +} + +augment enum E { + e2; + augment const E(); + augment const E.id(); +} + +extension type ET(int v) { + ET.foo(this.v) { + assert(v > 0); + } +} + +augment extension type ET { + augment ET(int v); + augment ET.foo(this.v); +} + +main() { + Expect.equals(0, C().v); + Expect.equals(2, C.id(1).v); + Expect.equals(1, ET(1).v); + Expect.equals(2, ET.foo(2).v); + if (assertStatementsEnabled) { + Expect.throws(() { + ET.foo(0); + }); + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t05.dart new file mode 100644 index 0000000000..b27ac26b13 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t05.dart @@ -0,0 +1,95 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that introductory and augmented bodies are executed with +/// the same parameters. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import '../../Utils/expect.dart'; + +String log = ""; + +class C { + C(int x, [int y = 0]) { + log += "C(${x++}, ${y++});"; + } + C.foo(int x, {int y = 0}) { + log += "C.foo(${x++}, ${y++});"; + } + C.bar({required int x}) { + log += "C.bar(${x++});"; + } +} + +augment class C { + augment C(int x, [int y = 0]) { + log += "C($x, $y);"; + } + augment C.foo(int x, {int y = 0}) { + log += "C($x, $y);"; + } + augment C.bar({required int x}) { + log += "C.bar($x);"; + } +} + +extension type ET(int id) { + ET.foo(this.id, [int y = 0]) { + log += "ET.foo($id, ${y++});"; + } + ET.bar(this.id, {int y = 0}) { + log += "ET.bar($id, ${y++});"; + } + ET.baz({required this.id, required int y}) { + log += "ET.baz($id, ${y++});"; + } +} + +augment extension type ET { + augment ET.foo(this.id, [int y = 0]) { + log += "ET.foo($id, $y);"; + } + augment ET.bar(this.id, {int y = 0}) { + log += "ET.bar($id, $y);"; + } + augment ET.baz({required this.id, required int y}) { + log += "ET.baz($id, $y);"; + } +} + +void checkLog(String expected) { + Expect.equals(expected, log); + log = ""; +} + +main() { + C(1); + checkLog("C(1, 0);C(1, 0);"); + C(1, 2); + checkLog("C(1, 2);C(1, 2);"); + C.foo(1); + checkLog("C.foo(1, 0);C.foo(1, 0);"); + C.foo(1, y: 2); + checkLog("C.foo(1, 2);C.foo(1, 2);"); + C.bar(x: 1); + checkLog("C.bar(1);C.bar(1);"); + + ET.foo(1); + checkLog("ET.foo(1, 0);ET.foo(1, 0);"); + ET.foo(1, 2); + checkLog("ET.foo(1, 2);ET.foo(1, 2);"); + ET.bar(1); + checkLog("ET.bar(1, 0);ET.bar(1, 0);"); + ET.bar(1, y: 2); + checkLog("ET.bar(1, 2);ET.bar(1, 2);"); + ET.baz(id: 1, y: 1); + checkLog("ET.baz(1, 2);ET.baz(1, 2);",); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t06.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t06.dart new file mode 100644 index 0000000000..c3e6b25112 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t06.dart @@ -0,0 +1,60 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that it is a compile-time error if an introductory +/// constructor accesses local variables defined in an augmenting constructor +/// and vice versa. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + int x = 0; + print(y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +augment class C { + augment C() { + int y = 0; + print(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(int id) { + ET.foo(this.id) { + int x = 0; + print(y); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +augment extension type ET { + augment ET.foo(this.id) { + int y = 0; + print(x); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07.dart new file mode 100644 index 0000000000..d39da31e65 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07.dart @@ -0,0 +1,84 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that non-redirecting generative constructor bodies are +/// invoked in augmentation order, starting at the introductory declaration. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import '../../Utils/expect.dart'; +part 'augmenting_constructors_A09_t07_lib1.dart'; +part 'augmenting_constructors_A09_t07_lib3.dart'; + +String log = ""; + +class C { + C() { + log += "Introductory;"; + } + C.id() { + log += "Introductory;"; + } + + augment C() { + log += "Augment 1;"; + } + augment C.id() { + log += "Augment 1;"; + } +} + +augment class C { + augment C() { + log += "Augment 2;"; + } + augment C.id() { + log += "Augment 2;"; + } +} + +extension type ET(int id) { + ET.foo(this.id) { + log += "Introductory;"; + } + + augment ET(int id) { + log += "Augment 1;"; + } + augment ET.foo(this.id) { + log += "Augment 1;"; + } +} + +augment extension type ET { + augment ET.new(int id) { + log += "Augment 2;"; + } + augment ET.foo(this.id) { + log += "Augment 2;"; + } +} + +void checkLog(String expected) { + Expect.equals(expected, log); + log = ""; +} + +main() { + C(); + checkLog("Introductory;Augment 1;Augment 2;Augment 3;Augment 4;Augment 5;"); + C.id(); + checkLog("Introductory;Augment 1;Augment 2;Augment 3;Augment 4;Augment 5;"); + + ET(0); + checkLog("Augment 1;Augment 2;Augment 3;Augment 4;Augment 5;"); + ET.foo(0); + checkLog("Introductory;Augment 1;Augment 2;Augment 3;Augment 4;Augment 5;"); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib1.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib1.dart new file mode 100644 index 0000000000..34280368dc --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib1.dart @@ -0,0 +1,35 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that non-redirecting generative constructor bodies are +/// invoked in augmentation order, starting at the introductory declaration. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A09_t07.dart'; +part 'augmenting_constructors_A09_t07_lib2.dart'; + +augment class C { + augment C() { + log += "Augment 3;"; + } + augment C.id() { + log += "Augment 3;"; + } +} + +augment extension type ET { + augment ET(int id) { + log += "Augment 3;"; + } + augment ET.foo(this.id) { + log += "Augment 3;"; + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib2.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib2.dart new file mode 100644 index 0000000000..458e716d40 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib2.dart @@ -0,0 +1,34 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that non-redirecting generative constructor bodies are +/// invoked in augmentation order, starting at the introductory declaration. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A09_t07_lib1.dart'; + +augment class C { + augment C() { + log += "Augment 4;"; + } + augment C.id() { + log += "Augment 4;"; + } +} + +augment extension type ET { + augment ET.new(int id) { + log += "Augment 4;"; + } + augment ET.foo(this.id) { + log += "Augment 4;"; + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib3.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib3.dart new file mode 100644 index 0000000000..98112d72e8 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A09_t07_lib3.dart @@ -0,0 +1,34 @@ +// 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 At a high level, a non-redirecting generative constructor marked +/// `augment` may: +/// - Augment the constructor with an additional constructor body (bodies are +/// invoked in augmentation order, starting at the introductory declaration). +/// +/// @description Checks that non-redirecting generative constructor bodies are +/// invoked in augmentation order, starting at the introductory declaration. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +part of 'augmenting_constructors_A09_t07.dart'; + +augment class C { + augment C() { + log += "Augment 5;"; + } + augment C.id() { + log += "Augment 5;"; + } +} + +augment extension type ET { + augment ET(int id) { + log += "Augment 5;"; + } + augment ET.foo(this.id) { + log += "Augment 5;"; + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t01.dart deleted file mode 100644 index 90cc5a0533..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t01.dart +++ /dev/null @@ -1,42 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that in the augmenting constructor's body, an -/// `augmented()` call executes the augmented constructor's body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_constructors_A10_t01_lib.dart'; - -String _log = ""; - -class C { - C() { - _log += "Original;"; - } -} - -extension type ET(int id) { - ET.foo(this.id) { - _log += "Original;"; - } -} - -main() { - C(); - Expect.equals("Original;Original;Augmented", _log); - _log = ""; - ET(0); - Expect.equals("Original;Original;Augmented", _log); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t01_lib.dart deleted file mode 100644 index e53a1e8016..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t01_lib.dart +++ /dev/null @@ -1,35 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that in the augmenting constructor's body, an -/// `augmented()` call executes the augmented constructor's body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t01.dart'; - -augment class C { - augment C() { - augmented(); - augmented(); - _log += "Augmented"; - } -} - -augment extension type ET { - augment ET.foo(this.id) { - augmented(); - augmented(); - _log += "Augmented"; - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t02.dart deleted file mode 100644 index 2bace249ac..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t02.dart +++ /dev/null @@ -1,33 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to call `augmented()` in -/// the augmenting constructor's body if the augmented constructor has no body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A10_t02_lib.dart'; - -class C { - C(); - // TODO (sgrekhov): add factory constructors after https://github.com/dart-lang/language/issues/4025 -} - -extension type ET(int id) { - ET.foo(this.id); -} - -main() { - print(C); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t02_lib.dart deleted file mode 100644 index fce23c349c..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t02_lib.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 A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to call `augmented()` in -/// the augmenting constructor's body if the augmented constructor has no body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t02.dart'; - -augment class C { - augment C() { - augmented(); -// ^^^^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -augment extension type ET { - augment ET.foo(this.id) { - augmented(); -// ^^^^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t03.dart deleted file mode 100644 index 7972a8b168..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t03.dart +++ /dev/null @@ -1,80 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that in the augmenting constructor's body, an -/// `augmented()` call executes the augmented constructor's body in the same -/// parameter scope that the augmenting body is executing in. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_constructors_A10_t03_lib.dart'; - -String _log = ""; - -class C { - C(int x, [int y = 0]) { - _log += "C($x, $y);"; - } - C.foo(int x, {int y = 0}) { - _log += "C.foo($x, $y);"; - } - C.bar({required int x}) { - _log += "C.bar($x);"; - } -} - -extension type ET(int id) { - ET.foo(this.id, [int y = 0]) { - _log += "ET.foo($id, $y);"; - } - ET.bar(this.id, {int y = 0}) { - _log += "ET.bar($id, $y);"; - } - ET.baz({required this.id}) { - _log += "ET.baz($id);"; - } -} - -main() { - C(1); - Expect.equals("C(1, 0);C(2, 1);", _log); - _log = ""; - C(1, 2); - Expect.equals("C(1, 2);C(2, 3);", _log); - _log = ""; - C.foo(1); - Expect.equals("C.foo(1, 0);C.foo(2, 1);", _log); - _log = ""; - C.foo(1, y: 2); - Expect.equals("C.foo(1, 2);C.foo(2, 3);", _log); - _log = ""; - C.bar(1); - Expect.equals("C.bar(1);C.bar(2);", _log); - _log = ""; - - ET.foo(1); - Expect.equals("ET.foo(1, 0);ET.foo(1, 1);", _log); - _log = ""; - ET.foo(1, 2); - Expect.equals("ET.foo(1, 2);ET.foo(1, 3);", _log); - _log = ""; - ET.bar(1); - Expect.equals("ET.bar(1, 0);ET.bar(1, 1);", _log); - _log = ""; - ET.bar(1, y: 2); - Expect.equals("ET.bar(1, 2);ET.bar(1, 3);", _log); - _log = ""; - ET.baz(1); - Expect.equals("ET.baz(1);ET.baz(1);", _log); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t03_lib.dart deleted file mode 100644 index 6cd8a6dcb8..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t03_lib.dart +++ /dev/null @@ -1,57 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that in the augmenting constructor's body, an -/// `augmented()` call executes the augmented constructor's body in the same -/// parameter scope that the augmenting body is executing in. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t03.dart'; - -augment class C { - augment C(int x, [int y = 0]) { - _log += "C($x, $y);"; - x++; - y++; - augmented(); - } - augment C.foo(int x, {int y = 0}) { - _log += "C.foo($x, $y);"; - x++; - y++; - augmented(); - } - augment C.bar({required int x}) { - _log += "C.bar($x);"; - x++; - augmented(); - } -} - -augment extension type ET { - augment ET.foo(this.id, [int y = 0]) { - _log += "ET.foo($id, $y);"; - y++; - augmented(); - } - augment ET.bar(this.id, {int y = 0}) { - _log += "ET.bar($id, $y);"; - y++; - augmented(); - } - augment ET.baz({required this.id}) { - _log += "ET.baz($id);"; - augmented(); - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t04.dart deleted file mode 100644 index 0c7877541f..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t04.dart +++ /dev/null @@ -1,34 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to specify any -/// parameters in an `augmented()`call in the augmenting constructor's body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A10_t04_lib.dart'; - -class C { - C(int x); - C.foo({int x = 0}); -} - -extension type ET(int id) { - ET.foo(this.id); - ET.bar({this.id = 0}); -} - -main() { - print(C); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t04_lib.dart deleted file mode 100644 index 94edc7f7d7..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t04_lib.dart +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to specify any -/// parameters in an `augmented()`call in the augmenting constructor's body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t04.dart'; - -augment class C { - augment C(int x) { - augmented(x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } - - augment C.foo({int x}) { - augmented(x: x); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -augment extension type ET { - augment ET.foo(this.id) { - augmented(id); -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - } - augment ET.bar(this.id) { - augmented(id: id); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t05.dart deleted file mode 100644 index 3f4629dfcf..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t05.dart +++ /dev/null @@ -1,32 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to tear-off `augmented` -/// in an augmenting constructor body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A10_t05_lib.dart'; - -class C { - C(); -} - -extension type ET(int id) { - ET.foo(this.id); -} - -main() { - print(C); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t05_lib.dart deleted file mode 100644 index 45c50ca46d..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t05_lib.dart +++ /dev/null @@ -1,45 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to tear-off `augmented` -/// in an augmenting constructor body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t05.dart'; - -augment class C { - augment C() { - augmented; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augmented.toString(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -augment extension type ET { - augment ET.foo(this.id) { - augmented; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augmented.toString(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t06.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t06.dart deleted file mode 100644 index 64fc0456fb..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t06.dart +++ /dev/null @@ -1,33 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to use the value -/// returned by the invocation of `augmented()` in an augmenting constructor -/// body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A10_t06_lib.dart'; - -class C { - C(); -} - -extension type ET(int id) { - ET.foo(this.id); -} - -main() { - print(C); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t06_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t06_lib.dart deleted file mode 100644 index 28d9ec452b..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t06_lib.dart +++ /dev/null @@ -1,38 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to use the value -/// returned by the invocation of `augmented()` in an augmenting constructor -/// body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t06.dart'; - -augment class C { - augment C() { - print(augmented()); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -augment extension type ET { - augment ET.foo(this.id) { - print(augmented()); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t08.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t08.dart deleted file mode 100644 index 90fb7dc19e..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t08.dart +++ /dev/null @@ -1,35 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that `augmented()` can be used inside on a function -/// literal in an augmenting constructor body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_constructors_A10_t08_lib.dart'; - -class C { - String? status; - Function? f; - C() { - status = "Original"; - } -} - -main() { - C c = C(); - Expect.equals("Augmented", c.status); - c.f?.call(); - Expect.equals("Original", c.status); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t08_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t08_lib.dart deleted file mode 100644 index 55ade89cf6..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t08_lib.dart +++ /dev/null @@ -1,28 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that `augmented()` can be used inside on a function -/// literal in an augmenting constructor body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t08.dart'; - -augment class C { - augment C() { - status = "Augmented"; - f = () { - augmented(); - }; - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t09.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t09.dart deleted file mode 100644 index 3b0c368fda..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t09.dart +++ /dev/null @@ -1,28 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to use an `augmented()` -/// in a non-augmenting constructor body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A10_t09_lib.dart'; - -class C {} - -extension type ET(int id) {} - -main() { - print(C); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t09_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t09_lib.dart deleted file mode 100644 index a93a163c98..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A10_t09_lib.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 A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - In the augmenting constructor's body, an `augmented()` call executes the -/// augmented constructor's body in the same parameter scope that the -/// augmenting body is executing in. The expression has type `void` and -/// evaluates to `null`. -/// -/// @description Checks that it is a compile-time error to use an `augmented()` -/// in a non-augmenting constructor body. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A10_t09.dart'; - -augment class C { - C() { - augmented(); -// ^^^^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -augment extension type ET { - ET.foo(this.id) { - augmented(); -// ^^^^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart index a866d0cfc2..6491c21401 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart @@ -2,19 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// -/// @description Checks that when `augmented()` is called in the body of an -/// augmenting constructor initializer lists are not re-run. +/// @description Checks that augmenting constructor may add initializers to the +/// initializer list. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros +import '../../Utils/expect.dart'; part 'augmenting_constructors_A11_t01_lib.dart'; class C { @@ -22,6 +22,26 @@ class C { C(): x = "Original"; } +enum E { + e0; + final String x, y; + const E(): x = "Original"; +} + +extension type ET(int v) { + ET.foo() : v = 0; +} + main() { - C(); + C c = C(); + Expect.equals("x", c.x); + Expect.equals("y", c.y); + + Expect.equals("Original", E.e0.x); + Expect.equals("Augmented", E.e0.y); + if (assertStatementsEnabled) { + Expect.throws(() { + ET.foo(); + }); + } } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart index e000df10a4..c07951a3a3 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart @@ -2,15 +2,14 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// -/// @description Checks that when `augmented()` is called in the body of an -/// augmenting constructor initializer lists are not re-run. +/// @description Checks that augmenting constructor may add initializers to the +/// initializer list. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -24,8 +23,14 @@ augment class C { Expect.equals("Augmented", y); x = "x"; y = "y"; - augmented(); - Expect.equals("x", x); - Expect.equals("y", y); } } + +augment enum E { + augment e0; + augment const E(): y = "Augmented"; +} + +augment extension type ET { + augment ET.foo() : assert(v > 0); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02.dart index e573f5173c..00d08ca5cd 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02.dart @@ -2,33 +2,37 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// -/// @description Checks that when `augmented()` is called in the body of an -/// augmenting constructor initializing formals are not re-run (no attempt to -/// reinitialize a final variable already initialized by initializing formals of -/// augmenting constructor). +/// @description Checks that when bodies of augmenting constructors are executed +/// initializing formals are not re-run (no attempt to reinitialize a final +/// variable already initialized by initializing formals of an introductory +/// constructor). /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros +import '../../Utils/expect.dart'; part 'augmenting_constructors_A11_t02_lib.dart'; class C { final String x; - C(this.x); + C(this.x) { + Expect.equals("x", x); + } } extension type ET(String id) { - ET.foo(this.id); + ET.foo(this.id) { + Expect.equals("x", id); + } } main() { - C("x"); - ET.foo("x"); + Expect.equals("x", C("x").x); + Expect.equals("x", ET("x").id); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02_lib.dart index 5ba71202fb..a0bbc12117 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t02_lib.dart @@ -2,17 +2,16 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// -/// @description Checks that when `augmented()` is called in the body of an -/// augmenting constructor initializing formals are not re-run (no attempt to -/// reinitialize a final variable already initialized by initializing formals of -/// augmenting constructor). +/// @description Checks that when bodies of augmenting constructors are executed +/// initializing formals are not re-run (no attempt to reinitialize a final +/// variable already initialized by initializing formals of an introductory +/// constructor). /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -23,13 +22,11 @@ import '../../Utils/expect.dart'; augment class C { augment C(this.x) { Expect.equals("x", x); - augmented(); } } augment extension type ET { augment ET.foo(this.id) { - Expect.equals("x", x); - augmented(); + Expect.equals("x", id); } } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03.dart index 0e1fe62b0c..1a02c38685 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03.dart @@ -2,21 +2,20 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// -/// @description Checks that when `augmented()` is called in the body of an -/// augmenting constructor super parameters are not passed twice to a -/// superinitializer (no attempt to reinitialize a final variable already -/// initialized by augmenting constructor). +/// @description Checks that when bodies of augmenting constructors are executed +/// super parameters are not passed twice to a superinitializer (no attempt to +/// reinitialize a final variable already initialized by augmenting constructor) /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros +import '../../Utils/expect.dart'; part 'augmenting_constructors_A11_t03_lib.dart'; class A { @@ -25,9 +24,11 @@ class A { } class C extends A { - C(super.x); + C(super.x) { + Expect.equals("x", x); + } } main() { - C("x"); + Expect.equals("x", C("x").x); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03_lib.dart index ebdd4f2b69..e618916028 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t03_lib.dart @@ -2,17 +2,15 @@ // 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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// -/// @description Checks that when `augmented()` is called in the body of an -/// augmenting constructor super parameters are not passed twice to a -/// superinitializer (no attempt to reinitialize a final variable already -/// initialized by augmenting constructor). +/// @description Checks that when bodies of augmenting constructors are executed +/// super parameters are not passed twice to a superinitializer (no attempt to +/// reinitialize a final variable already initialized by augmenting constructor) /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -23,6 +21,5 @@ import '../../Utils/expect.dart'; augment class C { augment C(super.x) { Expect.equals("x", x); - augmented(); } } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t04.dart similarity index 60% rename from LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t01_lib.dart rename to LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t04.dart index d84093136c..0e0ee40730 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t04.dart @@ -2,13 +2,11 @@ // 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 non-redirecting generative constructor marked `augment` may: +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Add initializers to the initializer list. If the augmenting constructor -/// has an initializer list then: -/// - It's a compile-time error if the augmented constructor has -/// super-initializer, and the augmenting constructor's initializer list -/// also contains a super-initializer. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// /// @description Checks that it is a compile-time error if the augmented /// constructor has a super-initializer, and the augmenting constructor's @@ -17,7 +15,16 @@ // SharedOptions=--enable-experiment=macros -part of 'augmenting_constructors_A14_t01.dart'; +class A { + int x; + A(this.x); +} + +class C extends A { + int y; + int z; + C(int x, int y): this.y = y, super(x); +} augment class C { augment C(int x, int y): z = 1, super(x); @@ -25,3 +32,7 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified } + +main() { + print(C); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t05.dart similarity index 57% rename from LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t02.dart rename to LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t05.dart index efee055971..05ac2cb23f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t05.dart @@ -2,13 +2,11 @@ // 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 non-redirecting generative constructor marked `augment` may: +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Add initializers to the initializer list. If the augmenting constructor -/// has an initializer list then: -/// - It's a compile-time error if the augmented constructor has -/// super-initializer, and the augmenting constructor's initializer list -/// also contains a super-initializer. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// /// @description Checks that it is still a compile-time error if the augmenting /// constructor has a super-initializer not at the last position in the @@ -17,16 +15,18 @@ // SharedOptions=--enable-experiment=macros -part 'augmenting_constructors_A14_t02_lib.dart'; - class A { int x; - A(this.x); + A([this.x = 0]); } class C extends A { C(int x); -//^ +} + +augment class C { + augment C(int x): super(x), assert(x > 0); +// ^^^^^^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A15_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t06.dart similarity index 66% rename from LanguageFeatures/Augmentation-libraries/augmenting_constructors_A15_t01.dart rename to LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t06.dart index 8e41369718..294386de5f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A15_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t06.dart @@ -2,16 +2,11 @@ // 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 non-redirecting generative constructor marked `augment` may: +/// @assertion At a high level, a non-redirecting generative constructor marked +/// `augment` may: /// ... -/// - Add initializers to the initializer list. If the augmenting constructor -/// has an initializer list then: -/// ... -/// - Otherwise the result of applying the augmenting constructor has an -/// initializer list containing first the assertions and field initializers -/// of the augmented constructor, if any, then the assertions and field -/// initializers of the augmenting constructor, and finally any -/// super-initializer of either the augmented or augmenting constructor. +/// - Add initializers (and/or asserts) to the initializer list, as well as a +/// `super` call at the end of the initializer list. /// /// @description Checks that the result of applying the augmenting constructor /// has an initializer list containing first the assertions and field @@ -23,7 +18,6 @@ // SharedOptions=--enable-experiment=macros import '../../Utils/expect.dart'; -part 'augmenting_constructors_A15_t01_lib.dart'; class A { int z; @@ -37,6 +31,12 @@ class C extends A { C.bar(int x, int y, int z); } +augment class C { + augment C(int x, int y, int z): assert(x++ == 1), this.y = y; + augment C.foo(int x, int y, int z): this.y = y, assert(y++ == 1), super(++z); + augment C.bar(int x, int y, int z): this.x = x, this.y = y, super(z); +} + main() { C c1 = C(0, 0, 0); Expect.equals(0, c1.x); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.dart deleted file mode 100644 index 7cae125a92..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.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 A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - If a parameter variable is overwritten prior to calling `augmented()`, -/// the augmented body will see the updated value, because the parameter -/// scope is identical. -/// -/// @description Checks that if a parameter variable is overwritten prior to -/// calling `augmented()`, the augmented body see the updated value. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -import '../../Utils/expect.dart'; -part 'augmenting_constructors_A12_t01_lib.dart'; - -class C { - String x = ""; - String y = ""; - C(String v1, [String v2 = "default"]) { - x = v1; - y = v2; - } -} - -main() { - C c1 = C("Original"); - Expect.equals("Augmented", c1.x); - Expect.equals("Augmented", c1.y); - C c2 = C("Original", "Original"); - Expect.equals("Augmented", c2.x); - Expect.equals("Augmented", c2.y); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart deleted file mode 100644 index e1eaecd0ae..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart +++ /dev/null @@ -1,26 +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 non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - Initializer lists are not re-run, they have already executed and -/// shouldn't be executed twice. The same goes for initializing formals and -/// super parameters. -/// -/// @description Checks that if a parameter variable is overwritten prior to -/// calling `augmented()`, the augmented body see the updated value. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A12_t01.dart'; - -augment class C { - augment C(String v1, [String v2]) { - v1 = "Augmented"; - v2 = "Augmented"; - augmented(); - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A13_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A13_t01.dart deleted file mode 100644 index b17c8f822f..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A13_t01.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 A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - Local variables in scope where augmented is evaluated are not in scope -/// for the execution of the augmented constructor's body. -/// -/// @description Checks that it is a compile-time error if an introductory -/// constructor accesses local variables defined in an augmenting constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A13_t01_lib.dart'; - -class C { - C() { - x++; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -extension type ET(int id) { - ET.foo(this.id) { - x++; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - } -} - -main() { - print(C); - print(ET); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A13_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A13_t01_lib.dart deleted file mode 100644 index 5e1237acb3..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A13_t01_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 A non-redirecting generative constructor marked `augment` may: -/// - Add or replace the body of the augmented constructor with a new body. -/// ... -/// - Local variables in scope where augmented is evaluated are not in scope -/// for the execution of the augmented constructor's body. -/// -/// @description Checks that it is a compile-time error if an introductory -/// constructor accesses local variables defined in an augmenting constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A13_t01.dart'; - -augment class C { - augment C() { - int x = 0; - augmented(); - } -} - -augment extension type ET { - augment ET.foo(this.id) { - int x = 0; - augmented(); - } -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t01.dart deleted file mode 100644 index 0f07b5e46b..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t01.dart +++ /dev/null @@ -1,35 +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 non-redirecting generative constructor marked `augment` may: -/// ... -/// - Add initializers to the initializer list. If the augmenting constructor -/// has an initializer list then: -/// - It's a compile-time error if the augmented constructor has -/// super-initializer, and the augmenting constructor's initializer list -/// also contains a super-initializer. -/// -/// @description Checks that it is a compile-time error if the augmented -/// constructor has a super-initializer, and the augmenting constructor's -/// initializer list also contains a super-initializer. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A14_t01_lib.dart'; - -class A { - int x; - A(this.x); -} - -class C extends A { - int y; - int z = 0; - C(int x, int y): this.y = y, super(x); -} - -main() { - print(C); -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t02_lib.dart deleted file mode 100644 index fe51e90afa..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A14_t02_lib.dart +++ /dev/null @@ -1,27 +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 non-redirecting generative constructor marked `augment` may: -/// ... -/// - Add initializers to the initializer list. If the augmenting constructor -/// has an initializer list then: -/// - It's a compile-time error if the augmented constructor has -/// super-initializer, and the augmenting constructor's initializer list -/// also contains a super-initializer. -/// -/// @description Checks that it is still a compile-time error if the augmenting -/// constructor has a super-initializer not at the last position in the -/// initializer list. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A14_t02.dart'; - -augment class C { - augment C(int x): super(x), assert(x > 0); -// ^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A15_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A15_t01_lib.dart deleted file mode 100644 index f12c31598d..0000000000 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A15_t01_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 A non-redirecting generative constructor marked `augment` may: -/// ... -/// - Add initializers to the initializer list. If the augmenting constructor -/// has an initializer list then: -/// ... -/// - Otherwise the result of applying the augmenting constructor has an -/// initializer list containing first the assertions and field initializers -/// of the augmented constructor, if any, then the assertions and field -/// initializers of the augmenting constructor, and finally any -/// super-initializer of either the augmented or augmenting constructor. -/// -/// @description Checks that the result of applying the augmenting constructor -/// has an initializer list containing first the assertions and field -/// initializers of the augmented constructor, then the assertions and field -/// initializers of the augmenting constructor, and finally super-initializer of -/// either the augmented or augmenting constructor. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A15_t01.dart'; - -augment class C { - augment C(int x, int y, int z): assert(x++ == 1), this.y = y; - augment C.foo(int x, int y, int z): this.y = y, assert(y++ == 1), super(++z); - augment C.bar(int x, int y, int z): this.x = x, this.y = y, super(z); -}