diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31.dart index 2704c2691d..8430924134 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31.dart @@ -12,7 +12,7 @@ /// must immediately be invoked. /// /// @description Checks that it is a compile-time error to use `augmented` as a -/// constant value in a switch expressions and statements. +/// constant value in switch expressions and statements. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31_lib.dart index ef910bbea3..ad0b606c04 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t31_lib.dart @@ -12,7 +12,7 @@ /// must immediately be invoked. /// /// @description Checks that it is a compile-time error to use `augmented` as a -/// constant value in a switch expressions and statements. +/// constant value in switch expressions and statements. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t35_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t35_lib.dart index aeb3173820..c634f4d415 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t35_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t35_lib.dart @@ -23,8 +23,8 @@ augment String topLevelFunction1([String v]) => "Augmented: $v"; augment String topLevelFunction2({String v}) => "Augmented: $v"; augment class C { - augment factory C.f1([String v = augmented]) => C("Augmented: $v"); - augment factory C.f2({String v = augmented}) => C("Augmented: $v"); + augment factory C.f1([String v]) => C("Augmented: $v"); + augment factory C.f2({String v}) => C("Augmented: $v"); augment static String staticMethod1([String v]) => "Augmented: $v"; augment static String staticMethod2({String v}) => "Augmented: $v"; augment String instanceMethod1([String v]) => "Augmented: $v"; @@ -54,8 +54,8 @@ augment extension Ext { } augment extension type ET { - augment factory ET.f1([String v = augmented]) => ET("Augmented: $v"); - augment factory ET.f2({String v = augmented}) => ET("Augmented: $v"); + augment factory ET.f1([String v]) => ET("Augmented: $v"); + augment factory ET.f2({String v}) => ET("Augmented: $v"); augment static String staticMethod1([String v]) => "Augmented: $v"; augment static String staticMethod2({String v}) => "Augmented: $v"; augment String instanceMethod1([String v]) => "Augmented: $v"; diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t36.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t36.dart new file mode 100644 index 0000000000..1e46273276 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A04_t36.dart @@ -0,0 +1,348 @@ +// 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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting functions: Inside an augmenting function body (including +/// factory constructors but not generative constructors) `augmented` refers +/// to the augmented function. Tear-offs are not allowed, and this function +/// must immediately be invoked. +/// +/// @description Checks that it is a compile-time error if a variable with the +/// name `augmented` occurs in a control-flow element in an augmenting function +/// or a factory constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +var augmented = 0; + +void topLevelFunction() {} + +augment void topLevelFunction() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; +} + +class C { + C(); + factory C.f() => C(); + static void staticMethod() {} + void instanceMethod() {} +} + +augment class C { + augment factory C.f() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + return C(); + } + + augment static void staticMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + + augment void instanceMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +mixin M { + static void staticMethod() {} + void instanceMethod() {} +} + +augment mixin M { + augment static void staticMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + + augment void instanceMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +enum E { + e1; + static void staticMethod() {} + void instanceMethod() {} +} + +augment enum E { + augment e1; + augment static void staticMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + + augment void instanceMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +class A {} +extension Ext on A { + static void staticMethod() {} + void instanceMethod() {} +} + +augment extension Ext { + augment static void staticMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + + augment void instanceMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +extension type ET(int _) { + factory ET.f() => ET(0); + static void staticMethod() {} + void instanceMethod() {} +} + +augment extension type ET { + augment factory ET.f() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + return ET(0); + } + + augment static void staticMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + + augment void instanceMethod() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +main() { + print(topLevelFunction); + print(C); + print(M); + print(E); + print(A); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart index 40b45234c9..1ead2f8a58 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart @@ -82,5 +82,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart index 29039f5b73..2b7c1a4e51 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart @@ -78,5 +78,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart index 324a6d51fb..6c2e7f21b6 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart @@ -78,5 +78,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.dart index 8e8add713d..54690b8d3d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.dart @@ -76,5 +76,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.dart index 57258d8558..84d74a26e9 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.dart @@ -76,5 +76,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart index db5c659716..38e77ce9bd 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart @@ -78,5 +78,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart index 8f68d6304c..64646c8667 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart @@ -78,5 +78,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart index 851ef38ef3..3367281510 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart @@ -78,5 +78,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart index 03d5efa54a..da88948759 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart @@ -78,5 +78,6 @@ augment extension type ET { main() { print(C); + print(E); print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart index 5315079aaa..b859ef7829 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart @@ -70,7 +70,7 @@ augment extension type ET { // ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified - augment ET.foo(this.id, augmented id) {} + augment ET.foo(this.id, augmented x) {} // ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t21.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t21.dart new file mode 100644 index 0000000000..1fdb8b0823 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t21.dart @@ -0,0 +1,141 @@ +// 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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to use a type whose name is +/// `augmented` in an augmenting constructor body. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class augmented {} + +class C { + C() { + augmented? x; + var f = (augmented x) {}; + (augmented? x,) r = (null,); + } + C.foo() { + augmented? x; + var f = (augmented x) {}; + (augmented? x,) r = (null,); + } +} + +augment class C { + augment C() { + augmented? x; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + var f = (augmented x) {}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + (augmented? x,) r = (null,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + augmented? x; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + var f = (augmented x) {}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + (augmented? x,) r = (null,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + + C.bar() { + augmented? x; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + var f = (augmented x) {}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + (augmented? x,) r = (null,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(int id) { + ET.foo(this.id) { + augmented? x; + var f = (augmented x) {}; + (augmented? x,) r = (null,); + } +} + +augment extension type ET { + augment ET.new(int id) { + augmented? x; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + var f = (augmented x) {}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + (augmented? x,) r = (null,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + + augment ET.foo(this.id) { + augmented? x; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + var f = (augmented x) {}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + (augmented? x,) r = (null,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + + ET.bar(this.id) { + augmented? x; +//^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + var f = (augmented x) {}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + (augmented? x,) r = (null,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t22.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t22.dart new file mode 100644 index 0000000000..c39ed5f431 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t22.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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to augment a +/// non-redirecting generative constructor whose name is `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C1 { + C1.augmented(); +} + +augment class C1 { + augment C1.augmented() {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +class C2 {} + +augment class C2 { + C2.augmented() {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E1 { + e0; + const E1(); + const E1.augmented(); +} + +augment enum E1 { + e1; + augment const E1.augmented(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E2 { + e0; + const E2(); +} + +augment enum E2 { + e1; + const E2.augmented(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET1(int id) { + ET1.augmented(this.id); +} + +augment extension type ET1 { + augment ET1.augmented(this.id) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET2(int id) {} + +augment extension type ET2 { + ET2.augmented(this.id) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C1); + print(C2); + print(E1); + print(E2); + print(ET1); + print(ET2); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t23.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t23.dart new file mode 100644 index 0000000000..a1dc0a7716 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t23.dart @@ -0,0 +1,90 @@ +// 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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to call a function with +/// a named parameter whose name is `augmented` in a body of a non-redirecting +/// generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +int test({int augmented = 0}) => augmented + 42; + +class C { + C() { + test(augmented: 1); + } + C.foo() { + test(augmented: 1); + } +} + +augment class C { + augment C() { + test(); // Ok + test(augmented: 1); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + test(); // Ok + test(augmented: 1); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + test(); // Ok + test(augmented: 1); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(int id) { + ET.foo(this.id) { + test(augmented: 1); + } +} + +augment extension type ET { + augment ET(int id) { + test(); // Ok + test(augmented: 1); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this.id) { + test(); // Ok + test(augmented: 1); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this.id) { + test(); // Ok + test(augmented: 1); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t24.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t24.dart new file mode 100644 index 0000000000..006e4b7579 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t24.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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to use a record with +/// a named parameter whose name is `augmented` in a body of a non-redirecting +/// generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +int test({int augmented = 0}) => augmented + 42; + +class C { + C() { + print((augmented: 1)); + } + C.foo() { + print((augmented: 1)); + } +} + +augment class C { + augment C() { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(int id) { + ET.foo(this.id) { + print((augmented: 1)); + } +} + +augment extension type ET { + augment ET(int id) { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this.id) { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this.id) { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t25.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t25.dart new file mode 100644 index 0000000000..c4a0f8f3f7 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t25.dart @@ -0,0 +1,135 @@ +// 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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to use `augmented` as a +/// constant value in switch expressions and statements within the body of a +/// non-redirecting generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +const augmented = "Constant augmented, shouldn't be used"; + +class C { + C() { + switch ("") { + case augmented: + default: + } + var x = switch("") { + augmented => 1, + _ => 0 + }; + } + C.foo() { + switch ("") { + case augmented: + default: + } + var x = switch("") { + augmented => 1, + _ => 0 + }; + } +} + +augment class C { + augment C() { + switch ("") { + case augmented: +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + default: + } + var x = switch("") { + augmented => 1, +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + _ => 0 + }; + } + augment C.foo() { + switch ("") { + case augmented: +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + default: + } + var x = switch("") { + augmented => 1, +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + _ => 0 + }; + } + C.bar() { + switch ("") { + case augmented: +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + default: + } + var x = switch("") { + augmented => 1, +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + _ => 0 + }; + } +} + +extension type ET(int id) { + ET.foo(this.id) { + switch ("") { + case augmented: + default: + } + var x = switch("") { + augmented => 1, + _ => 0 + }; + } +} + +augment extension type ET { + augment ET(int id) { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this.id) { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this.id) { + print((augmented: 1)); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t26.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t26.dart new file mode 100644 index 0000000000..d5d90588fd --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t26.dart @@ -0,0 +1,111 @@ +// 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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to use a type whose name +/// is `augmented` in `is` and `as` expressions within the body of a +/// non-redirecting generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +typedef augmented = Null; + +class C { + C() { + print(null as augmented); + print(null is augmented); + } + C.foo() { + print(null as augmented); + print(null is augmented); + } +} + +augment class C { + augment C() { + print(null as augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(null is augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + print(null as augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(null is augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + print(null as augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(null is augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(int id) { + ET.foo(this.id) { + print(null as augmented); + print(null is augmented); + } +} + +augment extension type ET { + augment ET(int id) { + print(null as augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(null is augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.foo(this.id) { + print(null as augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(null is augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this.id) { + print(null as augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + print(null is augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t27.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t27.dart new file mode 100644 index 0000000000..79dfe60478 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t27.dart @@ -0,0 +1,192 @@ +// 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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error if a variable named +/// `augmented` is used within a control-flow element within the body of a +/// non-redirecting generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +var augmented = 0; + +class C { + C() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 + ]; + var map = { + for (var i = 0; i > augmented;) i: i + }; + var set = { + if (1 > augmented) 42 + }; + } + C.foo() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 + ]; + var map = { + for (var i = 0; i > augmented;) i: i + }; + var set = { + if (1 > augmented) 42 + }; + } +} + +augment class C { + augment C() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + augment C.foo() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + C.bar() { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +extension type ET(int id) { + ET.foo(this.id) { + var list = [ + for (var augmented = 0; 1 > 2;) 0 + ]; + var map = { + for (var i = 0; i > augmented;) i: i + }; + var set = { + if (1 > augmented) 42 + }; + } +} + +augment extension type ET { + augment ET(int id) { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + ET.foo(this.id) { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } + ET.bar(this.id) { + var list = [ + for (var augmented = 0; 1 > 2;) 0 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ]; + var map = { + for (var i = 0; i > augmented;) i: i +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + var set = { + if (1 > augmented) 42 +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + }; + } +} + +main() { + print(C); + print(ET); +}