diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart index 1004dc7efc..9ebe754f76 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart @@ -6,8 +6,8 @@ /// ... /// A non-writable variable declaration is augmented with a setter. /// -/// @description Checks that it is a compile-time error if a non-writable -/// variable declaration is augmented with a setter. +/// @description Checks that it is a compile-time error if an implicitly induced +/// getter of a final variable declaration is augmented with a setter. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -38,7 +38,7 @@ extension Ext on A { static final String staticVariable = "staticVariable"; } -extension type ET(String _) { +extension type ET(String id) { static final String staticVariable = "staticVariable"; } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart index 3dd789ae44..b01d169d52 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart @@ -6,9 +6,8 @@ /// ... /// A non-writable variable declaration is augmented with a setter. /// -/// @description Checks that it is a compile-time error if an augmenting -/// declaration uses `augmented` when the augmented declaration has no concrete -/// implementation. +/// @description Checks that it is a compile-time error if an implicitly induced +/// getter of a final variable declaration is augmented with a setter. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros @@ -65,5 +64,9 @@ augment extension type ET { augment static void set staticVariable(String _) {} //^^^^^^^ // [analyzer] unspecified +// [cfe] unspecified + augment static void set id(String _) {} +//^^^^^^^ +// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02.dart index 60026eaf17..078df4dab4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02.dart @@ -6,39 +6,40 @@ /// ... /// A non-writable variable declaration is augmented with a setter. /// -/// @description Checks that it is a compile-time error if a non-writable -/// variable declaration is augmented with a setter. Test `late final` variables +/// @description Checks that it is a compile-time error if an implicitly induced +/// getter of a `late final` variable declaration with an initializer is +/// augmented with a setter. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros import augment 'augmenting_members_A02_t02_lib.dart'; -late final String topLevelVariable; +late final String topLevelVariable = ""; class C { - static late final String staticVariable; - late final String instanceVariable; + static late final String staticVariable = ""; + late final String instanceVariable = ""; } mixin M { - static late final String staticVariable; - late final String instanceVariable; + static late final String staticVariable = ""; + late final String instanceVariable = ""; } enum E { e0; - static late final String staticVariable; + static late final String staticVariable = ""; } class A {} extension Ext on A { - static late final String staticVariable; + static late final String staticVariable = ""; } extension type ET(String _) { - static late final String staticVariable; + static late final String staticVariable = ""; } main() { diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart index 45591f42d4..0d8621b557 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart @@ -6,8 +6,9 @@ /// ... /// A non-writable variable declaration is augmented with a setter. /// -/// @description Checks that it is a compile-time error if a non-writable -/// variable declaration is augmented with a setter. Test `late final` variables +/// @description Checks that it is a compile-time error if an implicitly induced +/// getter of a `late final` variable declaration with an initializer is +/// augmented with a setter. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart index fe642d21e0..3a70a4a64e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart @@ -6,8 +6,8 @@ /// ... /// A non-writable variable declaration is augmented with a setter. /// -/// @description Checks that it is a compile-time error if a non-writable -/// variable declaration is augmented with a setter. Test `const` variables. +/// @description Checks that it is a compile-time error if a `const` variable +/// declaration is augmented with a setter. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart index dc5c2d4fdf..59d63db07e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart @@ -6,8 +6,8 @@ /// ... /// A non-writable variable declaration is augmented with a setter. /// -/// @description Checks that it is a compile-time error if a non-writable -/// variable declaration is augmented with a setter. Test `const` variables. +/// @description Checks that it is a compile-time error if a `const` variable +/// declaration is augmented with a setter. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=macros diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04.dart new file mode 100644 index 0000000000..69c0e05395 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04.dart @@ -0,0 +1,54 @@ +// 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-writable variable declaration is augmented with a setter. +/// +/// @description Checks that it is a compile-time error if a getter declaration +/// is augmented with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A02_t04_lib.dart'; + +String get topLevelGetter => "topLevelGetter"; + +class C { + static String get staticGetter => "staticGetter"; + String get instanceGetter => "instanceGetter"; +} + +mixin M { + static String get staticGetter => "staticGetter"; + String get instanceGetter => "instanceGetter"; +} + +enum E { + e0; + static String get staticGetter => "staticGetter"; + String get instanceGetter => "instanceGetter"; +} + +class A {} + +extension Ext on A { + static String get staticGetter => "staticGetter"; + String get instanceGetter => "instanceGetter"; +} + +extension type ET(String _) { + static String get staticGetter => "staticGetter"; + String get instanceGetter => "instanceGetter"; +} + +main() { + print(topLevelGetter); + print(C); + print(M); + print(E); + print(A); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04_lib.dart new file mode 100644 index 0000000000..a806a31f9c --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t04_lib.dart @@ -0,0 +1,76 @@ +// 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-writable variable declaration is augmented with a setter. +/// +/// @description Checks that it is a compile-time error if a getter declaration +/// is augmented with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A02_t04.dart'; + +/**/augment void set topLevelGetter(String _) {} +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +augment class C { + augment static void set staticGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment mixin M { + augment static void set staticGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment enum E { + augment e0; + augment static void set staticGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension Ext { + augment static void set staticGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment static void set staticGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceGetter(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05.dart new file mode 100644 index 0000000000..8bcbe9ff91 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05.dart @@ -0,0 +1,66 @@ +// 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-writable variable declaration is augmented with a setter. +/// +/// @description Checks that it is not an error to augment a `late final` +/// variable declaration with no initializer with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A02_t05_lib.dart'; +import '../../Utils/expect.dart'; + +String _log = ""; + +late final String topLevelVariable; + +class C { + static late final String staticVariable; + late final String instanceVariable; +} + +mixin M { + static late final String staticVariable; + late final String instanceVariable; +} + +enum E { + e0; + static late final String staticVariable; +} + +class A {} + +extension Ext on A { + static late final String staticVariable; +} + +extension type ET(String _) { + static late final String staticVariable; +} + +class MA = Object with M; + +main() { + topLevelVariable = "a"; + Expect.equals("Augmented: a", _log); + C.staticVariable = "b"; + Expect.equals("Augmented: b", _log); + C().instanceVariable = "c"; + Expect.equals("Augmented: c", _log); + M.staticVariable = "d"; + Expect.equals("Augmented: d", _log); + MA().instanceVariable = "e"; + Expect.equals("Augmented: e", _log); + E.staticVariable = "f"; + Expect.equals("Augmented: f", _log); + Ext.staticVariable = "g"; + Expect.equals("Augmented: g", _log); + ET.staticVariable = "h"; + Expect.equals("Augmented: h", _log); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05_lib.dart new file mode 100644 index 0000000000..6d26f30d9f --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t05_lib.dart @@ -0,0 +1,58 @@ +// 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-writable variable declaration is augmented with a setter. +/// +/// @description Checks that it is not an error to augment a `late final` +/// variable declaration with no initializer with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A02_t05.dart'; + +augment void set topLevelVariable(String v) { + _log = "Augmented: $v"; +} + +augment class C { + augment static void set staticVariable(String v) { + _log = "Augmented: $v"; + } + + augment void set instanceVariable(String v) { + _log = "Augmented: $v"; + } +} + +augment mixin M { + augment static void set staticVariable(String v) { + _log = "Augmented: $v"; + } + + augment void set instanceVariable(String v) { + _log = "Augmented: $v"; + } +} + +augment enum E { + augment e0; + augment static void set staticVariable(String v) { + _log = "Augmented: $v"; + } +} + +augment extension Ext { + augment static void set staticVariable(String v) { + _log = "Augmented: $v"; + } +} + +augment extension type ET { + augment static void set staticVariable(String v) { + _log = "Augmented: $v"; + } +}