diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A05_t01.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A05_t01.dart index 1a990f58be..9bc0ef92ac 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A05_t01.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A05_t01.dart @@ -2,19 +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 It is a compile-time error if: -/// ... -/// - The introductory constructor has a super initializer (super constructor -/// invocation at the end of the initializer list) and the augmenting -/// constructor does too. +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// /// @description Checks that it is a compile-time error if the introductory /// constructor has a super initializer and the augmenting constructor does too. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A05_t01_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class A { int x; @@ -26,10 +21,24 @@ class C1 extends A { C1(): super(0); } +augment class C1 { + augment C1(): super(0); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + class C2 extends A { C2(): super(0); } +augment class C2 { + augment C2(): super.foo(0); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C1); print(C2); diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A05_t01_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A05_t01_lib.dart deleted file mode 100644 index 48111883d0..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A05_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 It is a compile-time error if: -/// ... -/// - The introductory constructor has a super initializer (super constructor -/// invocation at the end of the initializer list) and the augmenting -/// constructor does too. -/// -/// @description Checks that it is a compile-time error if the introductory -/// constructor has a super initializer and the augmenting constructor does too. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A05_t01.dart'; - -augment class C1 { - augment C1(): super(0); -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment class C2 { - augment C2(): super.foo(0); -// ^^^^^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01.dart index 168b3b895b..ba75ef052d 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01.dart @@ -2,29 +2,56 @@ // 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). +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// -/// @description Checks that it is a compile-time error if the resulting -/// constructor has a redirecting initializer and initializer list elements. +/// @description Checks that it is a compile-time error if the introductory +/// constructor has a redirecting initializer and the augmenting has initializer +/// list elements. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A06_t01_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { int x; C(this.x); C.foo() : this(0); -//^^^^^ +} + +augment class C { + augment C.foo() : x = 1; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + e0.foo(); + final int x; + const E(this.x); + const E.foo() : this(0); +} + +augment enum E { + augment const E.foo() : x = 1; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int v) { + ET.foo() : this(0); +} + +augment extension type ET { + augment ET.foo() : x = 1; +// ^^^^^ // [analyzer] unspecified // [cfe] unspecified } main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01_lib.dart deleted file mode 100644 index 4cc7346966..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t01_lib.dart +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - The 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 initializer list elements. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A06_t01.dart'; - -augment class C { - augment C.foo() : x = 1; -} diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02.dart index d668079313..b99376da88 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02.dart @@ -2,19 +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 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). +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// -/// @description Checks that it is a compile-time error if the resulting -/// constructor has multiple super initializers. +/// @description Checks that it is a compile-time error if the introductory and +/// augmenting constructors have multiple super initializers. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A06_t02_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class A { int x; @@ -23,11 +18,16 @@ class A { class C extends A { C() : super(0); -//^ +} + +augment class C { + augment C() : super(1); +// ^ // [analyzer] unspecified // [cfe] unspecified } + main() { print(C); } diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02_lib.dart deleted file mode 100644 index 002827195f..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t02_lib.dart +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - The 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/Augmentations/augmenting_constructors_A06_t03.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t03.dart index 1ac8b145cb..88ccacf714 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t03.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t03.dart @@ -2,35 +2,67 @@ // 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). +/// @assertion The general rule is that compile-time errors apply to semantic +/// definitions whenever possible. In other words, if the library is +/// syntactically well-formed enough that augmentations can be applied, then +/// they should be. And if doing so eliminates what would otherwise be a +/// compile-time error, then that error should not be reported. /// /// @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_A06_t03_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(); C.foo(); } +augment class C { + augment C() : this(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo() : this.foo(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + enum E { e0; const E(); const E.foo(); } +augment enum E { + augment e0; + augment const E() : this(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo() : this.foo(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int v) { ET.foo(int v); } +augment extension type ET { + augment ET(int v) : this.foo(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(int v) : this(v); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t03_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t03_lib.dart deleted file mode 100644 index 296ff65452..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t03_lib.dart +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - The 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 a merged constructor -/// is cyclic. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A06_t03.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 v) : this.foo(v); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment ET.foo(int v) : this.foo(v); -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04.dart index c0c115c09f..7f0c178806 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04.dart @@ -2,19 +2,17 @@ // 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). +/// @assertion The general rule is that compile-time errors apply to semantic +/// definitions whenever possible. In other words, if the library is +/// syntactically well-formed enough that augmentations can be applied, then +/// they should be. And if doing so eliminates what would otherwise be a +/// compile-time error, then that error should not be reported. /// /// @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_A06_t04_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(); @@ -22,6 +20,21 @@ class C { C.bar(); } +augment class C { + augment C(): this.foo(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(): this.bar(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.bar(): this(); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + enum E { e0; const E(); @@ -29,11 +42,42 @@ enum E { const E.bar(); } +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 +} + extension type ET(int x) { ET.foo(int x); ET.bar(int x); } +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 +} + main() { print(C); print(E); diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04_lib.dart deleted file mode 100644 index 705fd6c943..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A06_t04_lib.dart +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - The 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 a merged constructor -/// is cyclic. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A06_t04.dart'; - -augment class C { - augment C(): this.foo(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.foo(): this.bar(); -// ^ -// [analyzer] unspecified -// [cfe] unspecified - augment C.bar(): this(); -// ^ -// [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/Augmentations/augmenting_constructors_A07_t01.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A07_t01.dart index df51007209..7fb5959b2d 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t01.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A07_t01.dart @@ -2,18 +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 It is a compile-time error if: -/// ... -/// - A non-redirecting constructor augments a constructor which is not -/// potentially non-redirecting. +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// /// @description Checks that it is a compile-time error if a non-redirecting /// constructor augments a constructor which is not potentially non-redirecting. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A07_t01_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class A {} @@ -21,7 +17,11 @@ class C extends A { int x; C(this.x); C.foo(): this(0); -//^^^^^ +} + +augment class C { + augment C.foo(): x = 1, super(0); +// ^^^^^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t01_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A07_t01_lib.dart deleted file mode 100644 index fab8397bff..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t01_lib.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - A non-redirecting constructor augments a constructor which is not -/// potentially non-redirecting. -/// -/// @description Checks that it is a compile-time error if a non-redirecting -/// constructor augments a constructor which is not potentially non-redirecting. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A07_t01.dart'; - -augment class C { - augment C.foo(): x = 1, super(0); -} diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02.dart index 1958459546..ab6165810e 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02.dart @@ -2,24 +2,24 @@ // 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: -/// ... -/// - A non-redirecting constructor augments a constructor which is not -/// potentially non-redirecting. +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// /// @description Checks that it is a compile-time error if a non-redirecting /// factory constructor augments a factory constructor which is not potentially /// non-redirecting. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A07_t02_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(); factory C.foo() = C; -//^^^^^ +} + +augment class C { + augment factory C.foo() => C(); +// ^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -29,6 +29,13 @@ extension type ET(int id) { factory ET.bar(int id) = ET.foo; } +augment extension type ET { + augment factory ET.bar(int id) => ET.foo(id); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(ET); diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02_lib.dart deleted file mode 100644 index 22ac626136..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A07_t02_lib.dart +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - A non-redirecting constructor augments a constructor which is not -/// potentially non-redirecting. -/// -/// @description Checks that it is a compile-time error if a non-redirecting -/// factory constructor augments a factory constructor which is not potentially -/// non-redirecting. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A07_t02.dart'; - -augment class C { - augment factory C.foo() => C(); -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment factory ET.bar(int id) => ET.foo(id); -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01.dart index b8cda6bf56..c76561d245 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01.dart @@ -2,28 +2,55 @@ // 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: -/// ... -/// - A redirecting constructor augments a constructor which is not potentially -/// redirecting. +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// /// @description Checks that it is a compile-time error if a redirecting /// constructor augments a constructor which is not potentially redirecting. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A08_t01_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { int x; C(this.x); C.foo(): x = 1; -//^^^^^ +} + +augment class C { + augment C.foo(): this(0); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + e0(0); + final int x; + const E(this.x); + const E.foo(): x = 1; +} + +augment enum E { + augment const E.foo(): this(0); +// ^^^^^ // [analyzer] unspecified // [cfe] unspecified } +extension type ET._(int x) { + const ET(this.x); + const ET.foo(): x = 1; +} + +augment extension type ET { + augment const ET.foo(): this(0); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01_lib.dart deleted file mode 100644 index 46354eeae9..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t01_lib.dart +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -/// @assertion It is a compile-time error if: -/// ... -/// - A redirecting constructor augments a constructor which is not potentially -/// redirecting. -/// -/// @description Checks that it is a compile-time error if a redirecting -/// constructor augments a constructor which is not potentially redirecting. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A08_t01.dart'; - -augment class C { - augment C.foo(): this(0); -} diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t02.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A08_t02.dart index 264573381c..df784876f3 100644 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t02.dart +++ b/LanguageFeatures/Augmentations/augmenting_constructors_A08_t02.dart @@ -2,30 +2,40 @@ // 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: -/// ... -/// - A redirecting constructor augments a constructor which is not potentially -/// redirecting. +/// @assertion It's a compile-time error if an augmentation is complete and any +/// declaration before it in the augmentation chain is also complete. /// /// @description Checks that it is a compile-time error if a redirecting /// factory constructor augments a factory constructor which is not potentially /// redirecting. /// @author sgrekhov22@gmail.com -// SharedOptions=--enable-experiment=macros - -part 'augmenting_constructors_A08_t02_lib.dart'; +// SharedOptions=--enable-experiment=augmentations class C { C(); factory C.foo() => C(); } +augment class C { + augment factory C.foo() = C; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + extension type ET(int id) { ET.foo(this.id); factory ET.bar(int id) => ET.foo(id); } +augment extension type ET { + augment factory ET.bar(int id) = ET.foo; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); print(ET); diff --git a/LanguageFeatures/Augmentations/augmenting_constructors_A08_t02_lib.dart b/LanguageFeatures/Augmentations/augmenting_constructors_A08_t02_lib.dart deleted file mode 100644 index c95a9bf0ed..0000000000 --- a/LanguageFeatures/Augmentations/augmenting_constructors_A08_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 It is a compile-time error if: -/// ... -/// - A redirecting constructor augments a constructor which is not potentially -/// redirecting. -/// -/// @description Checks that it is a compile-time error if a redirecting -/// constructor augments a constructor which is not potentially redirecting. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=macros - -part of 'augmenting_constructors_A08_t02.dart'; - -augment class C { - augment factory C.foo() = C; -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -augment extension type ET { - augment factory ET.bar(int id) = ET.foo; -// ^^^^^ -// [analyzer] unspecified -// [cfe] unspecified -}