From ec131d2a1e4fcb6b435c0e80804d6d3c71d05055 Mon Sep 17 00:00:00 2001 From: "Sergey G. Grekhov" Date: Mon, 4 Nov 2024 17:44:01 +0200 Subject: [PATCH 1/3] #2559. Add extension types and enums to augmented constructors --- .../augmented_expression_A07_t01.dart | 5 ++ .../augmented_expression_A07_t01_lib.dart | 7 ++ .../augmented_expression_A08_t01.dart | 2 + .../augmented_expression_A08_t01_lib.dart | 5 ++ .../augmented_expression_A08_t02.dart | 2 + .../augmented_expression_A08_t02_lib.dart | 5 ++ .../augmented_expression_A08_t03.dart | 2 + .../augmented_expression_A08_t03_lib.dart | 5 ++ .../augmented_expression_A08_t04.dart | 4 + .../augmented_expression_A08_t04_lib.dart | 9 +++ .../augmented_expression_A09_t01.dart | 2 + .../augmented_expression_A09_t01_lib.dart | 7 ++ .../augmented_expression_A09_t02.dart | 4 + .../augmented_expression_A09_t02_lib.dart | 14 ++++ .../augmented_expression_A09_t03.dart | 4 + .../augmented_expression_A09_t03_lib.dart | 14 ++++ .../augmented_expression_A09_t04.dart | 4 + .../augmented_expression_A09_t04_lib.dart | 14 ++++ .../augmented_expression_A09_t05.dart | 2 + .../augmented_expression_A09_t05_lib.dart | 12 +++ .../augmented_expression_A09_t06.dart | 2 + .../augmented_expression_A09_t06_lib.dart | 27 +++++++ .../augmented_expression_A09_t07.dart | 2 + .../augmented_expression_A09_t07_lib.dart | 52 +++++++++---- .../augmented_expression_A09_t08.dart | 2 + .../augmented_expression_A09_t08_lib.dart | 72 +++++++++++++---- .../augmented_expression_A09_t09.dart | 2 + .../augmented_expression_A09_t09_lib.dart | 27 +++++++ .../augmented_expression_A09_t10.dart | 2 + .../augmented_expression_A09_t10_lib.dart | 22 ++++++ .../augmented_expression_A09_t11.dart | 2 + .../augmented_expression_A09_t11_lib.dart | 11 +++ .../augmented_expression_A09_t13.dart | 2 + .../augmented_expression_A09_t13_lib.dart | 22 ++++++ .../augmenting_constructors_A02_t02.dart | 78 +++++++++++++++++++ .../augmenting_constructors_A03_t03.dart | 44 +++++++++++ .../augmenting_constructors_A03_t04.dart | 44 +++++++++++ .../augmenting_constructors_A06_t01.dart | 20 +++++ .../augmenting_constructors_A06_t01_lib.dart | 9 +++ .../augmenting_constructors_A06_t02.dart | 35 +++++++++ .../augmenting_constructors_A08_t01.dart | 20 +++++ .../augmenting_constructors_A08_t01_lib.dart | 9 +++ .../augmenting_constructors_A11_t01.dart | 5 ++ .../augmenting_constructors_A11_t01_lib.dart | 9 +++ .../augmenting_constructors_A12_t01.dart | 11 +++ .../augmenting_constructors_A12_t01_lib.dart | 7 ++ .../augmenting_constructors_A17_t01.dart | 33 ++++++++ .../augmenting_constructors_A17_t01_lib.dart | 13 ++++ .../augmenting_constructors_A17_t02.dart | 15 ++++ .../augmenting_constructors_A17_t02_lib.dart | 9 +++ 50 files changed, 701 insertions(+), 30 deletions(-) create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A02_t02.dart create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t03.dart create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t04.dart create mode 100644 LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01.dart index 2b4b41303a..d36c6db9b9 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01.dart @@ -32,6 +32,10 @@ extension Ext on A { A test() => this; } +extension type ET(int _) { + ET test() => this; +} + class MA = Object with M; main() { @@ -39,4 +43,5 @@ main() { MA().test(); E.e0.test(); A().test(); + ET(0).test(); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01_lib.dart index 604d8c46cf..889d61d2e6 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A07_t01_lib.dart @@ -42,3 +42,10 @@ augment extension Ext { return this; } } + +augment extension type ET { + augment ET test() { + Expect.identical(this, augmented()); + return this; + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01.dart index 932f1603ad..6004b055a0 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01.dart @@ -31,4 +31,6 @@ main() { Expect.equals("augmented", E.e1.instanceMethod()); Expect.equals("augmented", Ext.staticMethod()); Expect.equals("augmented", A().instanceMethod()); + Expect.equals("augmented", ET.staticMethod()); + Expect.equals("augmented", ET(0).instanceMethod()); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01_lib.dart index 50ef1ddab1..e6a0dd1131 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t01_lib.dart @@ -41,3 +41,8 @@ extension Ext on A { static String staticMethod() => augmented(); String instanceMethod() => augmented(); } + +extension type ET(int _) { + static String staticMethod() => augmented(); + String instanceMethod() => augmented(); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02.dart index ba1f9e5675..4f85bb3104 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02.dart @@ -31,4 +31,6 @@ main() { Expect.equals("augmented", E.e1.instanceMethod()); Expect.equals("augmented", Ext.staticMethod()); Expect.equals("augmented", A().instanceMethod()); + Expect.equals("augmented", ET.staticMethod()); + Expect.equals("augmented", ET(0).instanceMethod()); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02_lib.dart index 4d54cbabd3..baaf2d9e07 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t02_lib.dart @@ -41,3 +41,8 @@ extension Ext on A { static String staticMethod() => augmented; String instanceMethod() => augmented; } + +extension type ET(int _) { + static String staticMethod() => augmented; + String instanceMethod() => augmented; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03.dart index 3749780c1c..7014f4bcf4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03.dart @@ -31,4 +31,6 @@ main() { Expect.equals("augmented", E.e1.instanceMethod()); Expect.equals("augmented", Ext.staticMethod()); Expect.equals("augmented", A().instanceMethod()); + Expect.equals("augmented", ET.staticMethod()); + Expect.equals("augmented", ET(0).instanceMethod()); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03_lib.dart index beb9eefc9a..df49978f88 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t03_lib.dart @@ -41,3 +41,8 @@ extension Ext on A { static String staticMethod() => augmented; String instanceMethod() => augmented; } + +extension type ET(int _) { + static String staticMethod() => augmented; + String instanceMethod() => augmented; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04.dart index 9a1581241a..e42f6ed22b 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04.dart @@ -43,4 +43,8 @@ main() { Expect.equals("augmented = Ext.staticMethod", _log); A().instanceMethod(); Expect.equals("augmented = Ext.instanceMethod", _log); + ET.staticMethod(); + Expect.equals("augmented = ET.staticMethod", _log); + ET(0).instanceMethod(); + Expect.equals("augmented = ET.instanceMethod", _log); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04_lib.dart index 9ebb946fbc..6aec7333ad 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A08_t04_lib.dart @@ -59,3 +59,12 @@ extension Ext on A { augmented = "Ext.instanceMethod"; } } + +extension type ET(int _) { + static void staticMethod() { + augmented = "ET.staticMethod"; + } + void instanceMethod() { + augmented = "ET.instanceMethod"; + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01.dart index be591c4124..aab29735f9 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01.dart @@ -23,6 +23,7 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C1); @@ -31,4 +32,5 @@ main() { print(M2); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01_lib.dart index 556b97d4b6..0094af88e8 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t01_lib.dart @@ -57,3 +57,10 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static String augmented = "static"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02.dart index 5d8f21015b..2002912cf0 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02.dart @@ -25,6 +25,8 @@ enum E2 {e0;} class A {} extension Ext1 on A {} extension Ext2 on A {} +extension type ET1(int _) {} +extension type ET2(int _) {} main() { print(C1); @@ -34,4 +36,6 @@ main() { print(E1); print(E2); print(A); + print(ET1); + print(ET2); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02_lib.dart index 8bb8116d9d..cc603e90bf 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t02_lib.dart @@ -72,3 +72,17 @@ augment extension Ext2 { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET1 { + static String get augmented => "static"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET2 { + String get augmented => "instance"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03.dart index a6c63f4c47..3b92bb1f4e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03.dart @@ -25,6 +25,8 @@ enum E2 {e0;} class A {} extension Ext1 on A {} extension Ext2 on A {} +extension type ET1(int _) {} +extension type ET2(int _) {} main() { print(C1); @@ -34,4 +36,6 @@ main() { print(E1); print(E2); print(A); + print(ET1); + print(ET2); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03_lib.dart index 6eaecd41af..7d8d9d708e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t03_lib.dart @@ -72,3 +72,17 @@ augment extension Ext2 { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET1 { + static String augmented() => "static"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET2 { + String augmented() => "instance"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04.dart index 9c1a5f4f6a..c11499844e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04.dart @@ -25,6 +25,8 @@ enum E2 {e0;} class A {} extension Ext1 on A {} extension Ext2 on A {} +extension type ET1(int _) {} +extension type ET2(int _) {} main() { print(C1); @@ -34,4 +36,6 @@ main() { print(E1); print(E2); print(A); + print(ET1); + print(ET2); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04_lib.dart index b19bbfd8ee..c623cba769 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t04_lib.dart @@ -72,3 +72,17 @@ augment extension Ext2 { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET1 { + static void set augmented(String _) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET2 { + void set augmented(String _) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05.dart index 8f8da5454e..016cb45a6b 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05.dart @@ -21,10 +21,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05_lib.dart index 5a9fbbe62c..66d86497a3 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t05_lib.dart @@ -63,3 +63,15 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static void staticMethod(int v) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod(int v) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06.dart index 041f35082a..4c0a4fa2f1 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06.dart @@ -23,10 +23,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06_lib.dart index 6c2854c0b0..51ccc895e4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t06_lib.dart @@ -138,3 +138,30 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static augmented? staticVariable = null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static augmented? get staticGetter => null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static augmented? staticMethod() => null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augmented? get instanceGetter => null; +//^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + augmented? instanceMethod() => null; +//^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07.dart index c1ebc1e436..51afd2512e 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07.dart @@ -23,10 +23,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07_lib.dart index 1f78eaa48c..bedfcb2b22 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t07_lib.dart @@ -21,8 +21,8 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(augmented _) {} -// ^^^^^^^^^ + static void set staticSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -31,8 +31,8 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(augmented _) {} -// ^^^^^^^^^ + void set instanceSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -43,8 +43,8 @@ augment mixin M { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(augmented _) {} -// ^^^^^^^^^ + static void set staticSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -53,8 +53,8 @@ augment mixin M { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(augmented _) {} -// ^^^^^^^^^ + void set instanceSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -66,8 +66,8 @@ augment enum E { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(augmented _) {} -// ^^^^^^^^^ + static void set staticSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -76,8 +76,8 @@ augment enum E { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(augmented _) {} -// ^^^^^^^^^ + void set instanceSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -88,8 +88,8 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(augmented _) {} -// ^^^^^^^^^ + static void set staticSetter(augmented _) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -98,8 +98,30 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(augmented _) {} + void set instanceSetter(augmented _) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension ET { + static void staticMethod(augmented _) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static void set staticSetter(augmented _) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod(augmented _) {} // ^^^^^^^^^ // [analyzer] unspecified +// [cfe] unspecified + + void set instanceSetter(augmented _) {} +// ^^^^^^^^^ +// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08.dart index 2073e89d53..b5e3f1e282 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08.dart @@ -21,10 +21,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08_lib.dart index e3f96bd143..a18e507df4 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t08_lib.dart @@ -31,8 +31,8 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(int augmented) {} -// ^^^^^^^^^ + static void set staticSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -51,8 +51,8 @@ augment class C { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(int augmented) {} -// ^^^^^^^^^ + void set instanceSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -73,8 +73,8 @@ augment mixin M { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(int augmented) {} -// ^^^^^^^^^ + static void set staticSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -93,8 +93,8 @@ augment mixin M { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(int augmented) {} -// ^^^^^^^^^ + void set instanceSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -116,8 +116,8 @@ augment enum E { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(int augmented) {} -// ^^^^^^^^^ + static void set staticSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified @@ -136,8 +136,8 @@ augment enum E { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(int augmented) {} -// ^^^^^^^^^ + void set instanceSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } @@ -158,9 +158,51 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified - static void staticSetter(int augmented) {} + static void set staticSetter(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod1(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod2([int augmented = 0]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod3({int augmented = 0}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void set instanceSetter(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment extension type ET { + static void staticMethod1(int augmented) {} // ^^^^^^^^^ // [analyzer] unspecified +// [cfe] unspecified + + static void staticMethod2([int augmented = 0]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static void staticMethod3({int augmented = 0}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static void set staticSetter(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified // [cfe] unspecified void instanceMethod1(int augmented) {} @@ -178,8 +220,8 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified - void instanceSetter(int augmented) {} -// ^^^^^^^^^ + void set instanceSetter(int augmented) {} +// ^^^^^^^^^ // [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09.dart index 86a3dbb6f1..3a8debaa2c 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09.dart @@ -21,10 +21,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09_lib.dart index 05fb575272..82c247fd52 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t09_lib.dart @@ -138,3 +138,30 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static ({int augmented})? staticVariable = null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static ({int augmented})? staticMethod() => null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static ({int augmented})? get staticGetter => null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + ({int augmented})? instanceMethod(int augmented) => null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + ({int augmented})? get instanceGetter => null; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10.dart index 0ceeb6148d..ef3665f6ab 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10.dart @@ -21,10 +21,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10_lib.dart index 106ad7c8a6..376f8c5be7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t10_lib.dart @@ -103,3 +103,25 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static void staticMethod(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static void set staticSetter(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void set instanceSetter(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11.dart index 49e1c53a1b..b46bf67aea 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11.dart @@ -28,10 +28,12 @@ enum E { class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11_lib.dart index e3f79fb844..8324b5ed93 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t11_lib.dart @@ -60,3 +60,14 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static void staticMethod() {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + void instanceMethod() {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13.dart index 792fc8df6c..349b722dc8 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13.dart @@ -24,10 +24,12 @@ enum E {e0;} class A {} extension Ext on A {} +extension type ET(int _) {} main() { print(C); print(M); print(E); print(A); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13_lib.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13_lib.dart index 56a4a862ef..f7c4059e58 100644 --- a/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A09_t13_lib.dart @@ -104,3 +104,25 @@ augment extension Ext { // [analyzer] unspecified // [cfe] unspecified } + +augment extension type ET { + static void staticMethod1([String s = augmented]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + static void staticMethod2({String s = augmented}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod1([String s = augmented]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + void instanceMethod2({String s = augmented}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A02_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A02_t02.dart new file mode 100644 index 0000000000..5ea7589fd3 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A02_t02.dart @@ -0,0 +1,78 @@ +// 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 augmenting constructor parameters specify any default values. +/// +/// @description Checks that it is a compile-time error if the augmenting +/// factory constructor parameters specify any default values. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C([int x = 0]); + C.c1({int x = 0}); + factory C.c2([int x = 0]) => C(x); + factory C.c3({int x = 0}) => C.c1(x: x); +} + +augment class C { + augment factory C.c2([int x = 0]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment factory C.c3({int x = 0}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + e0(0); + const E([int x = 0]); + const E.c1({int x = 0}); + factory E.c2([int x = 0]) => E.e0; + factory E.c3({int x = 0}) => E.e0; +} + +augment enum E { + augment e0; + augment factory E.c2([int x = 0]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment factory E.c3({int x = 0}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + ET.c1(this.id, [int x = 0]); + ET.c2(this.id, {int x = 0}); + factory ET.c3(int id, [int x = 0]) => ET.c1(id, x); + factory ET.c4(int id, {int x = 0}) => ET.c2(id, x: x); +} + +augment extension type ET { + augment factory ET.c3([int x = 0]); +// ^ +// [analyzer] unspecified +// [cfe] unspecified + + augment factory ET.c4({int x = 0}); +// ^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(E); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t03.dart new file mode 100644 index 0000000000..fa035c1b55 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t03.dart @@ -0,0 +1,44 @@ +// 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 is `const` and the augmenting constructor is +/// not or vice versa. +/// +/// @description Checks that it is a compile-time error if the introductory +/// constructor is `const` and the augmenting constructor is not. Test factory +/// constructors. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + const C(); + const factory C.foo() = C; +} + +augment class C { + augment factory C.foo(); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + const ET.foo(this.id); + const factory ET.bar(int id) = ET.foo; +} + +augment extension type ET { + augment factory ET.bar(int id); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t04.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t04.dart new file mode 100644 index 0000000000..448c0b52f8 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A03_t04.dart @@ -0,0 +1,44 @@ +// 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 is `const` and the augmenting constructor is +/// not or vice versa. +/// +/// @description Checks that it is a compile-time error if the augmenting +/// constructor is `const` and the introductory constructor is not. Test factory +/// constructors. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + const C(); + factory C.foo() = C; +} + +augment class C { + augment const factory C.foo(); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + const ET.foo(this.id); + factory ET.bar(int id) = ET.foo; +} + +augment extension type ET { + augment const factory ET.bar(int id); +// ^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart index a9b22d047f..3ec1552eae 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01.dart @@ -10,6 +10,7 @@ /// @description Checks that it is a compile-time error if the resulting /// constructor has a redirecting initializer and other initializers. /// @author sgrekhov22@gmail.com +/// @issue 57029 // SharedOptions=--enable-experiment=macros @@ -24,6 +25,25 @@ class C { // [cfe] unspecified } +enum E { + e0(0), e1.foo(); + final int x; + const E(this.x); + const E.foo(): this(0); +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + ET.foo(): this(0); +//^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart index d17f573d7a..7196be8609 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t01_lib.dart @@ -18,3 +18,12 @@ part of 'augmenting_constructors_A06_t01.dart'; augment class C { augment C.foo(): x = 1; } + +augment enum E { + e2; + augment const E.foo(): x = 1; +} + +augment extension type ET { + augment ET.foo(): id = 1; +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart new file mode 100644 index 0000000000..6235fa6c5c --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion It is a compile-time error if: +/// ... +/// - The resulting constructor is not valid (has a redirecting initializer and +/// other initializers, multiple super initializers, etc). +/// +/// @description Checks that it is a compile-time error if the resulting +/// constructor has a redirecting initializer and other initializers. +/// @author sgrekhov22@gmail.com +/// @issue 57029 + +// SharedOptions=--enable-experiment=macros + +class A { + int x; + A([this.x = 0]); +} + +class C extends A { + C(): super(); +//^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +augment class C { + augment C(): super(1); +} + +main() { + print(C); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01.dart index b8cda6bf56..34b55e468d 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01.dart @@ -24,6 +24,26 @@ class C { // [cfe] unspecified } +enum E { + e0(0); + final int x; + const E(this.x); + const E.foo(): x = 1; +// ^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int x) { + ET.foo(this.x); + ET.bar(): x = 1; +//^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + main() { print(C); + print(E); + print(ET); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01_lib.dart index 46354eeae9..629677b792 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A08_t01_lib.dart @@ -18,3 +18,12 @@ part of 'augmenting_constructors_A08_t01.dart'; augment class C { augment C.foo(): this(0); } + +augment enum E { + e1(1); + augment const E.foo(): this(0); +} + +augment extension type ET { + augment ET.bar(): this(0); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart index a866d0cfc2..547b64c357 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01.dart @@ -12,6 +12,7 @@ /// @description Checks that when `augmented()` is called in the body of an /// augmenting constructor initializer lists are not re-run. /// @author sgrekhov22@gmail.com +/// @issue 56493 // SharedOptions=--enable-experiment=macros @@ -22,6 +23,10 @@ class C { C(): x = "Original"; } +extension type ET(String x) { + ET.foo(): x = "Original"; +} + main() { C(); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart index e000df10a4..440014a7f7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A11_t01_lib.dart @@ -12,6 +12,7 @@ /// @description Checks that when `augmented()` is called in the body of an /// augmenting constructor initializer lists are not re-run. /// @author sgrekhov22@gmail.com +/// @issue 56493 // SharedOptions=--enable-experiment=macros @@ -29,3 +30,11 @@ augment class C { Expect.equals("y", y); } } + +augment extension type ET { + augment ET.foo(): x = "Augmented" { + Expect.equals("Augmented", x); + augmented(); + Expect.equals("Augmented", x); + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.dart index 7cae125a92..0008dec7bf 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01.dart @@ -27,6 +27,14 @@ class C { } } +String log = ""; + +extension type ET(int x) { + ET.foo(this.x, String s) { + log = s; + } +} + main() { C c1 = C("Original"); Expect.equals("Augmented", c1.x); @@ -34,4 +42,7 @@ main() { C c2 = C("Original", "Original"); Expect.equals("Augmented", c2.x); Expect.equals("Augmented", c2.y); + + ET et = ET.foo(42, "Original"); + Expect.equals("Augmented", log); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart index e1eaecd0ae..e77c7cfbed 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart @@ -24,3 +24,10 @@ augment class C { augmented(); } } + +augment extension type ET(int x) { + augment ET.foo(this.x, String s) { + s = "Augmented"; + augmented(); + } +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart index 023d85df50..d5e6276ffb 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01.dart @@ -25,6 +25,25 @@ class C { C.bar(int x, {required int y}); } +enum E { + e0(0), e1.foo(1, y: 2), e2.bar(3, y: 4); + final int x, y; + const E(this.x, [this.y = 0]); + const E.foo(int x, {int y = 0}); + const E.bar(int x, {required int y}); +} + +int log = -1; + +extension type ET(int x) { + ET.foo(int x, int y) { + log = y; + } + ET.bar(int x, [int y = 0]); + ET.baz(int x, {int y = 0}); + ET.qux(int x, {required int y}); +} + main() { Expect.equals(1, C.foo(1).x); Expect.equals(0, C.foo(1).y); @@ -32,4 +51,18 @@ main() { Expect.equals(2, C.foo(1, y: 2).y); Expect.equals(1, C.bar(1, y: 2).x); Expect.equals(2, C.bar(1, y: 2).y); + + Expect.equals(1, E.e1.x); + Expect.equals(2, E.e1.y); + Expect.equals(3, E.e2.x); + Expect.equals(4, E.e2.y); + + Expect.equals(2, ET.foo(1, 2).x); + Expect.equals(1, log); + Expect.equals(3, ET.bar(3, 4).x); + Expect.equals(4, log); + Expect.equals(5, ET.baz(5, y: 6).x); + Expect.equals(6, log); + Expect.equals(7, ET.qux(7, y: 8).x); + Expect.equals(8, log); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart index 27977c2286..2f147dd4d6 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t01_lib.dart @@ -21,3 +21,16 @@ augment class C { augment C.foo(int x, {int y}): this(x, y); augment C.bar(int x, {required int y}): this.foo(x, y: y); } + +augment enum E { + augment e0; + augment const E.foo(int x, {int y}): this(x, y); + augment const E.bar(int x, {required int y}): this.foo(x, y: y); +} + +augment extension type ET { + augment ET.foo(int x, int y): this(x); + augment ET.bar(int x, [int y]): this.foo(x, y); + augment ET.baz(int x, {int y}): this.foo(x, y); + augment ET.qux(int x, {required int y}): this.foo(x, y); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart index 7c6c91197d..aee9b8e320 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02.dart @@ -24,6 +24,21 @@ class C { C.bar(int x): this(x + 1); } +enum E { + e0(0), e1.foo(1), e2.foo(2); + final int x; + const E(this.x); + const E.foo(int x): this(x + 1); + const E.bar(int x): this(x + 1); +} + +extension type ET(int x) { + ET.foo(int x): this(x + 1); + ET.bar(int x): this(x + 1); +} + main() { Expect.equals(3, C.bar(1).x); + Expect.equals(3, E.e2.x); + Expect.equals(3, ET.bar(1).x); } diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart index 3953343e42..df28e11a1a 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart @@ -19,3 +19,12 @@ part of 'augmenting_constructors_A17_t02.dart'; augment class C { augment C.bar(int x): this.foo(x + 1); } + +augment enym E { + augment e0; + augment E.bar(int x): this.foo(x + 1); +} + +augment extension type ET { + augment ET.bar(int x): this.foo(x + 1); +} From f1a468e0d0ecdf01abf02a7dbf9f246574565a12 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Wed, 6 Nov 2024 16:28:28 +0200 Subject: [PATCH 2/3] Fix typos and make spec parser happy --- .../augmenting_constructors_A12_t01_lib.dart | 2 +- .../augmenting_constructors_A17_t02_lib.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart index e77c7cfbed..a13c41084f 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A12_t01_lib.dart @@ -25,7 +25,7 @@ augment class C { } } -augment extension type ET(int x) { +augment extension type ET { augment ET.foo(this.x, String s) { s = "Augmented"; augmented(); diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart index df28e11a1a..14b9d1e4f6 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A17_t02_lib.dart @@ -20,7 +20,7 @@ augment class C { augment C.bar(int x): this.foo(x + 1); } -augment enym E { +augment enum E { augment e0; augment E.bar(int x): this.foo(x + 1); } From 4f087d91a4791ea090ea16b9a8fd09a77b21e5a3 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Tue, 26 Nov 2024 10:41:05 +0200 Subject: [PATCH 3/3] Resolve a merge conflict --- ...tructors_A06_t02.dart => augmenting_constructors_A06_t03.dart} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename LanguageFeatures/Augmentation-libraries/{augmenting_constructors_A06_t02.dart => augmenting_constructors_A06_t03.dart} (100%) diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t03.dart similarity index 100% rename from LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02.dart rename to LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t03.dart