diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart new file mode 100644 index 0000000000..9ebe754f76 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01.dart @@ -0,0 +1,52 @@ +// 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 an implicitly induced +/// getter of a final variable declaration is augmented with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A02_t01_lib.dart'; + +final String topLevelVariable = "topLevelVariable"; + +class C { + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +mixin M { + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +enum E { + e0; + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +class A {} + +extension Ext on A { + static final String staticVariable = "staticVariable"; +} + +extension type ET(String id) { + static final String staticVariable = "staticVariable"; +} + +main() { + print(topLevelVariable); + print(C); + print(M); + print(E); + print(A); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart new file mode 100644 index 0000000000..b01d169d52 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t01_lib.dart @@ -0,0 +1,72 @@ +// 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 an implicitly induced +/// getter of a final variable declaration is augmented with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A02_t01.dart'; + +/**/augment void set topLevelVariable(String _) {} +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +augment class C { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment mixin M { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment enum E { + augment e0; + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension Ext { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +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 new file mode 100644 index 0000000000..078df4dab4 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02.dart @@ -0,0 +1,52 @@ +// 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 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 = ""; + +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 = ""; +} + +main() { + print(topLevelVariable); + print(C); + print(M); + print(E); + print(A); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart new file mode 100644 index 0000000000..0d8621b557 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t02_lib.dart @@ -0,0 +1,65 @@ +// 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 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 + +augment library 'augmenting_members_A02_t02.dart'; + +/**/augment void set topLevelVariable(String _) {} +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +augment class C { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment mixin M { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment void set instanceVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment enum E { + augment e0; + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension Ext { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart new file mode 100644 index 0000000000..3a70a4a64e --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03.dart @@ -0,0 +1,49 @@ +// 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 `const` variable +/// declaration is augmented with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A02_t03_lib.dart'; + +const topLevelVariable = "topLevelVariable"; + +class C { + static const staticVariable = "staticVariable"; +} + +mixin M { + static const staticVariable = "staticVariable"; +} + +enum E { + e0; + static const staticVariable = "staticVariable"; +} + +class A {} + +extension Ext on A { + static const staticVariable = "staticVariable"; +} + +extension type ET(String _) { + static const staticVariable = "staticVariable"; +} + +main() { + print(topLevelVariable); + print(C); + print(M); + print(E); + print(A); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart new file mode 100644 index 0000000000..59d63db07e --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A02_t03_lib.dart @@ -0,0 +1,56 @@ +// 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 `const` variable +/// declaration is augmented with a setter. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A02_t03.dart'; + +/**/augment void set topLevelVariable(String _) {} +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +augment class C { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment mixin M { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment enum E { + augment e0; + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension Ext { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment static void set staticVariable(String _) {} +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} 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"; + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A03_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A03_t01.dart new file mode 100644 index 0000000000..a25d50e392 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A03_t01.dart @@ -0,0 +1,51 @@ +// 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-final variable is augmented with a final variable. +/// +/// @description Checks that it is a compile-time error if a non-final variable +/// is augmented with a final variable. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A03_t01_lib.dart'; + +String topLevelVariable = "topLevelVariable"; + +class C { + static String staticVariable = "staticVariable"; + String instanceVariable = "instanceVariable"; +} + +mixin M { + static String staticVariable = "staticVariable"; + String instanceVariable = "instanceVariable"; +} + +enum E { + e0; + static String staticVariable = "staticVariable"; +} + +class A {} + +extension Ext on A { + static String staticVariable = "staticVariable"; +} + +extension type ET(String _) { + static String staticVariable = "staticVariable"; +} + +main() { + print(topLevelVariable); + print(C); + print(M); + print(E); + print(A); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A03_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A03_t01_lib.dart new file mode 100644 index 0000000000..275d0a381d --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A03_t01_lib.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 It is a compile-time error if: +/// ... +/// A non-final variable is augmented with a final variable. +/// +/// @description Checks that it is a compile-time error if a non-final variable +/// is augmented with a final variable. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A03_t01.dart'; + +/**/augment final String topLevelVariable = "Augmented"; +// ^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + +augment class C { + augment static final String staticVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment final String instanceVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment mixin M { + augment static final String staticVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment final String instanceVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment enum E { + augment e0; + augment static final String staticVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension Ext { + augment static final String staticVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + augment static final String staticVariable = "Augmented"; +//^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t01.dart new file mode 100644 index 0000000000..cb91824f58 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t01.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 A final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that a final variable can be augmented with a non-final +/// augmenting variable. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A04_t01_lib.dart'; +import '../../Utils/expect.dart'; + +final String topLevelVariable = "topLevelVariable"; + +class C { + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +mixin M { + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +enum E { + e0; + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +class A {} + +extension Ext on A { + static final String staticVariable = "staticVariable"; +} + +extension type ET(String _) { + static final String staticVariable = "staticVariable"; +} + +class MA = Object with M; + +main() { + Expect.equals("Augmented", topLevelVariable); + Expect.equals("Augmented", C.staticVariable); + Expect.equals("Augmented", C().instanceVariable); + Expect.equals("Augmented", M.staticVariable); + Expect.equals("Augmented", MA().instanceVariable); + Expect.equals("Augmented", E.staticVariable); + Expect.equals("Augmented", E.e0.instanceVariable); + Expect.equals("Augmented", Ext.staticVariable); + Expect.equals("Augmented", ET.staticVariable); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t01_lib.dart new file mode 100644 index 0000000000..04d0096a92 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t01_lib.dart @@ -0,0 +1,41 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that a final variable can be augmented with a non-final +/// augmenting variable. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A04_t01.dart'; + +augment String topLevelVariable = "Augmented"; + +augment class C { + augment static String staticVariable = "Augmented"; + augment String instanceVariable = "Augmented"; +} + +augment mixin M { + augment static String staticVariable = "Augmented"; + augment String instanceVariable = "Augmented"; +} + +augment enum E { + augment e0; + augment static String staticVariable = "Augmented"; + augment String instanceVariable = "Augmented"; +} + +augment extension Ext { + augment static String staticVariable = "Augmented"; +} + +augment extension type ET { + augment static String staticVariable = "Augmented"; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t02.dart new file mode 100644 index 0000000000..6025e7d4b1 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t02.dart @@ -0,0 +1,56 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that a final `late` variable can be augmented with a +/// non-final `late` augmenting variable. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A04_t02_lib.dart'; +import '../../Utils/expect.dart'; + +late final String topLevelVariable = "topLevelVariable"; + +class C { + static late final String staticVariable = "staticVariable"; + late final String instanceVariable = "instanceVariable"; +} + +mixin M { + static late final String staticVariable = "staticVariable"; + late final String instanceVariable = "instanceVariable"; +} + +enum E { + e0; + static late final String staticVariable = "staticVariable"; +} + +class A {} + +extension Ext on A { + static late final String staticVariable = "staticVariable"; +} + +extension type ET(String _) { + static late final String staticVariable = "staticVariable"; +} + +class MA = Object with M; + +main() { + Expect.equals("Augmented", topLevelVariable); + Expect.equals("Augmented", C.staticVariable); + Expect.equals("Augmented", C().instanceVariable); + Expect.equals("Augmented", M.staticVariable); + Expect.equals("Augmented", MA().instanceVariable); + Expect.equals("Augmented", E.staticVariable); + Expect.equals("Augmented", Ext.staticVariable); + Expect.equals("Augmented", ET.staticVariable); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t02_lib.dart new file mode 100644 index 0000000000..c30a892b97 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t02_lib.dart @@ -0,0 +1,40 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that a final `late` variable can be augmented with a +/// non-final `late` augmenting variable. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A04_t02.dart'; + +augment late String topLevelVariable = "Augmented"; + +augment class C { + augment static late String staticVariable = "Augmented"; + augment late String instanceVariable = "Augmented"; +} + +augment mixin M { + augment static late String staticVariable = "Augmented"; + augment late String instanceVariable = "Augmented"; +} + +augment enum E { + augment e0; + augment static late String staticVariable = "Augmented"; +} + +augment extension Ext { + augment static late String staticVariable = "Augmented"; +} + +augment extension type ET { + augment static late String staticVariable = "Augmented"; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t03.dart new file mode 100644 index 0000000000..4c5862f3a9 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t03.dart @@ -0,0 +1,65 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that a final `late` variable can be augmented with a +/// non-final `late` augmenting variable. Test the case when augmentation has +/// no initializing value. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A04_t03_lib.dart'; +import '../../Utils/expect.dart'; + +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 = "topLevelVariable"; + Expect.equals("topLevelVariable", topLevelVariable); + C.staticVariable = "staticVariable"; + Expect.equals("staticVariable", C.staticVariable); + C().instanceVariable = "instanceVariable"; + Expect.equals("instanceVariable", C().instanceVariable); + M.staticVariable = "staticVariable"; + Expect.equals("staticVariable", M.staticVariable); + MA().instanceVariable = "instanceVariable"; + Expect.equals("instanceVariable", MA().instanceVariable); + E.staticVariable = "staticVariable"; + Expect.equals("staticVariable", E.staticVariable); + Ext.staticVariable = "staticVariable"; + Expect.equals("staticVariable", Ext.staticVariable); + ET.staticVariable = "staticVariable"; + Expect.equals("staticVariable", ET.staticVariable); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t03_lib.dart new file mode 100644 index 0000000000..9cf6fbb5d6 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t03_lib.dart @@ -0,0 +1,41 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that a final `late` variable can be augmented with a +/// non-final `late` augmenting variable. Test the case when augmentation has +/// no initializing value. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A04_t03.dart'; + +augment late String topLevelVariable; + +augment class C { + augment static late String staticVariable; + augment late String instanceVariable; +} + +augment mixin M { + augment static late String staticVariable; + augment late String instanceVariable; +} + +augment enum E { + augment e0; + augment static late String staticVariable; +} + +augment extension Ext { + augment static late String staticVariable; +} + +augment extension type ET { + augment static late String staticVariable; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t04.dart new file mode 100644 index 0000000000..fadeb05282 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t04.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 A final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that if a final variable is augmented with a non-final +/// augmenting variable then it is still a compile-time error to write to it. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A04_t04_lib.dart'; + +final String topLevelVariable = "topLevelVariable"; + +class C { + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +mixin M { + static final String staticVariable = "staticVariable"; + final String instanceVariable = "instanceVariable"; +} + +enum E { + e0; + static final String staticVariable = "staticVariable"; + final String instanceVariable = "staticVariable"; +} + +class A {} + +extension Ext on A { + static final String staticVariable = "staticVariable"; +} + +extension type ET(String _) { + static final String staticVariable = "staticVariable"; +} + +class MA = Object with M; + +main() { + topLevelVariable = ""; +//^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C().instanceVariable = ""; +// ^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + M.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + MA().instanceVariable = ""; +// ^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + E.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + E.e0.instanceVariable = ""; +// ^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + Ext.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t04_lib.dart new file mode 100644 index 0000000000..3ed41ec367 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t04_lib.dart @@ -0,0 +1,41 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that if a final variable is augmented with a non-final +/// augmenting variable then it is still a compile-time error to write to it. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A04_t04.dart'; + +augment String topLevelVariable = "Augmented"; + +augment class C { + augment static String staticVariable = "Augmented"; + augment String instanceVariable = "Augmented"; +} + +augment mixin M { + augment static String staticVariable = "Augmented"; + augment String instanceVariable = "Augmented"; +} + +augment enum E { + augment e0; + augment static String staticVariable = "Augmented"; + augment String instanceVariable = "Augmented"; +} + +augment extension Ext { + augment static String staticVariable = "Augmented"; +} + +augment extension type ET { + augment static String staticVariable = "Augmented"; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05.dart new file mode 100644 index 0000000000..8c84a571c7 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05.dart @@ -0,0 +1,80 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that if a final `late` variable is augmented with a +/// non-final `late` augmenting variable then it is still a compile-time error +/// to write to it. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +import augment 'augmenting_members_A04_t05_lib.dart'; + +late final String topLevelVariable = "topLevelVariable"; + +class C { + static late final String staticVariable = "staticVariable"; + late final String instanceVariable = "instanceVariable"; +} + +mixin M { + static late final String staticVariable = "staticVariable"; + late final String instanceVariable = "instanceVariable"; +} + +enum E { + e0; + static late final String staticVariable = "staticVariable"; +} + +class A {} + +extension Ext on A { + static late final String staticVariable = "staticVariable"; +} + +extension type ET(String _) { + static late final String staticVariable = "staticVariable"; +} + +class MA = Object with M; + +main() { + topLevelVariable = ""; +//^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C().instanceVariable = ""; +// ^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + M.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + MA().instanceVariable = ""; +// ^^^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + E.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + Ext.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.staticVariable = ""; +// ^^^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05_lib.dart new file mode 100644 index 0000000000..b85774f5dc --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_members_A04_t05_lib.dart @@ -0,0 +1,41 @@ +// 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 final variable can be augmented with a non-final augmenting +/// variable, and that will not add any setter. An augmenting variable +/// declaration only affects the initializer expression, not setters. +/// +/// @description Checks that if a final `late` variable is augmented with a +/// non-final `late` augmenting variable then it is still a compile-time error +/// to write to it. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +augment library 'augmenting_members_A04_t05.dart'; + +augment late String topLevelVariable = "Augmented"; + +augment class C { + augment static late String staticVariable = "Augmented"; + augment late String instanceVariable = "Augmented"; +} + +augment mixin M { + augment static late String staticVariable = "Augmented"; + augment late String instanceVariable = "Augmented"; +} + +augment enum E { + augment e0; + augment static late String staticVariable = "Augmented"; +} + +augment extension Ext { + augment static late String staticVariable = "Augmented"; +} + +augment extension type ET { + augment static late String staticVariable = "Augmented"; +}