diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t01.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t01.dart new file mode 100644 index 0000000000..4469278e5b --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t01.dart @@ -0,0 +1,107 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to use an `augmented` in +/// the body of an augmenting non-redirecting generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + var augmented = "Ok, not augmenting declaration"; + print(augmented); + } + C.foo() { + var augmented = "Ok, not augmenting declaration"; + print(augmented); + } +} + +augment class C { + augment C() { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET1(int _) { + ET1.foo(this._) { + var augmented = "Ok, not augmenting declaration"; + print(augmented); + } +} + +augment extension type ET1 { + augment ET1(int _) { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET1.foo(this._) { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET1.bar(this._) { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET2.id(int _) { + ET2.new(this._) { + var augmented = "Ok, not augmenting declaration"; + print(augmented); + } +} + +augment extension type ET2 { + augment ET2.id(this._) { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET2(this._) { + var augmented = "Error, within the scope of an augmenting declaration"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET1); + print(ET2); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t02.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t02.dart new file mode 100644 index 0000000000..5e7fa9e863 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t02.dart @@ -0,0 +1,103 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to call an `augmented()` +/// expression in the body of an augmenting non-redirecting generative +/// constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C(); + C.foo(); + String augmented() => "Ok, non-augmenting declaration"; +} + +augment class C { + augment C() { + augmented(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + augmented(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + augmented(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET1(String _) { + ET1.foo(this._) { + augmented("Ok, non-augmenting declaration"); + } + void augmented(String _) {} +} + +augment extension type ET1 { + augment ET1(int _) { + augmented("Error!"); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET1.foo(this._) { + augmented("Error!"); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET1.bar(this._) { + augmented("Error!"); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET2.foo(String _) { + ET2.new(this._) { + augmented("Ok, non-augmenting declaration"); + } + void augmented(String _) {} +} + +augment extension type ET2 { + augment ET2.foo(this._) { + augmented("Error!"); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET2(this._) { + augmented("Error!"); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET1); + print(ET2); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t03.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t03.dart new file mode 100644 index 0000000000..163bd315f6 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t03.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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to tear-off a function +/// named `augmented()` in the body of an augmenting non-redirecting generative +/// constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C(); + C.foo(); + String augmented() => "Ok, non-augmenting declaration"; +} + +augment class C { + augment C() { + var v = augmented; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + augmented.toString(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + augmented.toString(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(String _) { + ET.foo(this._) { + augmented("Ok, non-augmenting declaration"); + } + void augmented(String _) {} +} + +augment extension type ET { + augment ET(int _) { + var v = augmented; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this._) { + augmented.toString(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this._) { + augmented.toString(); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t04.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t04.dart new file mode 100644 index 0000000000..1e88ce42d2 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t04.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// function named `augmented()` in the body of an augmenting non-redirecting +/// generative constructor. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + String augmented() => "Ok, non-augmenting declaration"; + } + C.foo() { + String augmented() => "Ok, non-augmenting declaration"; + } +} + +augment class C { + augment C() { + String augmented() => "Error!"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + String augmented() => "Error!"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + String augmented() => "Error!"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(String _) { + ET.foo(this._) { + String augmented() => "Ok, non-augmenting declaration"; + } +} + +augment extension type ET { + augment ET(int _) { + String augmented() => "Error!"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this._) { + String augmented() => "Error!"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this._) { + String augmented() => "Error!"; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t05.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t05.dart new file mode 100644 index 0000000000..e4b6887e5e --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t05.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// variable named `augmented` in the body of an augmenting non-redirecting +/// generative constructor. Test a variable pattern. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + switch((1,)) { + case (var augmented,): + } + } + C.id() { + switch([1]) { + case [var augmented]: + } + } +} + +augment class C { + augment C() { + switch((1,)) { + case (var augmented,): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } + augment C.id() { + switch([1]) { + case [var augmented]: +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } +} + +extension type ET(String _) { + ET.id(this._) { + switch((1,)) { + case (var augmented,): + } + } +} + +augment extension type ET { + augment ET(int _) { + switch((1,)) { + case (var augmented,): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } + augment ET.id(this._) { + switch([1]) { + case [var augmented]: +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t06.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t06.dart new file mode 100644 index 0000000000..bbe1c283da --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t06.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// variable named `augmented` in the body of an augmenting non-redirecting +/// generative constructor. Test a parenthesized pattern. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + var (augmented) = (42); + } + C.foo() { + var (augmented) = (42); + } +} + +augment class C { + augment C() { + var (augmented) = (42); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + var (augmented) = (42); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + var (augmented) = (42); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(String _) { + ET.foo(this._) { + var (augmented) = (42); + } +} + +augment extension type ET { + augment ET(int _) { + var (augmented) = (42); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this._) { + var (augmented) = (42); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this._) { + var (augmented) = (42); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t07.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t07.dart new file mode 100644 index 0000000000..60951b7415 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t07.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// variable named `augmented` in the body of an augmenting non-redirecting +/// generative constructor. Test a list pattern. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + var [augmented] = [42]; + } + C.foo() { + var [augmented] = [42]; + } +} + +augment class C { + augment C() { + var [augmented] = [42]; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + var [augmented] = [42]; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + var [augmented] = [42]; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(String _) { + ET.foo(this._) { + var [augmented] = [42]; + } +} + +augment extension type ET { + augment ET(int _) { + var [augmented] = [42]; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this._) { + var [augmented] = [42]; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this._) { + var [augmented] = [42]; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t08.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t08.dart new file mode 100644 index 0000000000..acc0a29966 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t08.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// variable named `augmented` in the body of an augmenting non-redirecting +/// generative constructor. Test a map pattern. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + var {"key": augmented} = {"key": 42}; + } + C.foo() { + var {"key": augmented} = {"key": 42}; + } +} + +augment class C { + augment C() { + var {"key": augmented} = {"key": 42}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + var {"key": augmented} = {"key": 42}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + var {"key": augmented} = {"key": 42}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(String _) { + ET.foo(this._) { + var {"key": augmented} = {"key": 42}; + } +} + +augment extension type ET { + augment ET(int _) { + var {"key": augmented} = {"key": 42}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this._) { + var {"key": augmented} = {"key": 42}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this._) { + var {"key": augmented} = {"key": 42}; +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t09.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t09.dart new file mode 100644 index 0000000000..5aca818d92 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t09.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// variable named `augmented` in the body of an augmenting non-redirecting +/// generative constructor. Test a record pattern. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + var (augmented,) = (42,); + } + C.foo() { + var (augmented,) = (42,); + } +} + +augment class C { + augment C() { + var (augmented,) = (42,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment C.foo() { + var (augmented,) = (42,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + C.bar() { + var (augmented,) = (42,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +extension type ET(String _) { + ET.foo(this._) { + var (augmented,) = (42,); + } +} + +augment extension type ET { + augment ET(int _) { + var (augmented,) = (42,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + augment ET.foo(this._) { + var (augmented,) = (42,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + ET.bar(this._) { + var (augmented,) = (42,); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t10.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t10.dart new file mode 100644 index 0000000000..2e3b6dfd33 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t10.dart @@ -0,0 +1,100 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error to declare a local +/// variable named `augmented` in the body of an augmenting non-redirecting +/// generative constructor. Test an object pattern. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C() { + switch(1) { + case int(isEven: var augmented): + } + } + C.foo() { + switch(1) { + case int(isEven: var augmented): + } + } +} + +augment class C { + augment C() { + switch(1) { + case int(isEven: var augmented): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } + augment C.foo() { + switch(1) { + case int(isEven: var augmented): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } + C.bar() { + switch(1) { + case int(isEven: var augmented): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } +} + +extension type ET(String _) { + ET.foo(this._) { + switch(1) { + case int(isEven: var augmented): + } + } +} + +augment extension type ET { + augment ET(int _) { + switch(1) { + case int(isEven: var augmented): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } + augment ET.foo(this._) { + switch(1) { + case int(isEven: var augmented): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } + ET.bar(this._) { + switch(1) { + case int(isEven: var augmented): +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + } + } +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart new file mode 100644 index 0000000000..40b45234c9 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t11.dart @@ -0,0 +1,86 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to declare a positional parameter +/// named `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C(int augmented); + C.foo(int augmented); +} + +augment class C { + augment C(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(0), a1.foo(1); + const E(int augmented); + const E.foo(int augmented); +} + +augment enum E { + a2.bar(2); + augment const E(int augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(int augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar(int augmented); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int augmented) { + ET.foo(this.augmented); +} + +augment extension type ET { + augment ET(int augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(this.augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(this.augmented) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart new file mode 100644 index 0000000000..29039f5b73 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t12.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to declare a named parameter with the +/// name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C({int augmented = 0}); + C.foo({int augmented = 0}); +} + +augment class C { + augment C({int augmented}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo({int augmented}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar({int augmented = 0}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(), a1.foo(); + const E({int augmented = 0}); + const E.foo({int augmented = 0}); +} + +augment enum E { + a2.bar(); + augment const E({int augmented}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo({int augmented}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar({int augmented}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int augmented) { + ET.foo({this.augmented = 0}); +} + +augment extension type ET { + augment ET.foo({this.augmented}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar({this.augmented = 0}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart new file mode 100644 index 0000000000..324a6d51fb --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t13.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to declare a optional positional +/// parameter with the name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C([int augmented = 0]); + C.foo([int augmented = 0]); +} + +augment class C { + augment C([int augmented]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo([int augmented]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar([int augmented = 0]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(), a1.foo(); + const E([int augmented = 0]); + const E.foo([int augmented = 0]); +} + +augment enum E { + a2.bar(); + augment const E([int augmented]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo([int augmented]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar([int augmented]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int augmented) { + ET.foo([this.augmented = 0]); +} + +augment extension type ET { + augment ET.foo([this.augmented]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar([this.augmented = 0]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.dart new file mode 100644 index 0000000000..8e8add713d --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t14.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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as a positional parameter a +/// record with a positional field with the name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C((int augmented,) r); + C.foo((int augmented,) r); +} + +augment class C { + augment C((int augmented,) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo((int augmented,) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar((int augmented,) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0((0,)), a1.foo((1,)); + const E((int augmented,) r); + const E.foo((int augmented,) r); +} + +augment enum E { + a2.bar((2,)); + augment const E((int augmented,) r); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo((int augmented,) r); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar((int augmented,) r); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET((int augmented,) r) {} + +augment extension type ET { + augment ET.new((int augmented,) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar((int augmented,) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.dart new file mode 100644 index 0000000000..57258d8558 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t15.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 The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as a positional parameter a +/// record with a with a named field with the name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C(({int augmented}) r); + C.foo(({int augmented}) r); +} + +augment class C { + augment C(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(null), a1.foo(null); + const E(({int augmented})? r); + const E.foo(({int augmented})? r); +} + +augment enum E { + a2.bar(null); + augment const E(({int augmented})? r); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(({int augmented})? r); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar(({int augmented})? r); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(({int augmented}) r) {} + +augment extension type ET { + augment ET.new(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(({int augmented}) r) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart new file mode 100644 index 0000000000..db5c659716 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t16.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as an optional positional +/// parameter a record with a positional field named `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C([(int augmented,) r = (0,)]); + C.foo([(int augmented,) r = (0,)]); +} + +augment class C { + augment C([(int augmented,) r]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo([(int augmented,) r]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar([(int augmented,) r = (0,)]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(), a1.foo(); + const E([(int augmented,) r = (0,)]); + const E.foo([(int augmented,) r = (0,)]); +} + +augment enum E { + a2.bar(); + augment const E([(int augmented,) r]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo([(int augmented,) r]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar([(int augmented,) r]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + ET.foo(this.id, [(int augmented,) r = (0,)]); +} + +augment extension type ET { + augment ET.foo(this.id, [(int augmented,) r]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(this.id, [(int augmented,) r = (0,)]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart new file mode 100644 index 0000000000..8f68d6304c --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t17.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as an optional positional +/// parameter a record with a named field with the name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C([({int augmented}) r = (augmented: 0)]); + C.foo([({int augmented}) r = (augmented: 0)]); +} + +augment class C { + augment C([({int augmented}) r]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo([({int augmented}) r]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar([({int augmented}) r = (augmented: 0)]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(), a1.foo(); + const E([({int augmented}) r = (augmented: 0)]); + const E.foo([({int augmented}) r = (augmented: 0)]); +} + +augment enum E { + a2.bar(); + augment const E([({int augmented}) r]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo([({int augmented}) r]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar([({int augmented}) r = (augmented: 0)]); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + ET.foo(this.id, [({int augmented}) r = (augmented: 0)]); +} + +augment extension type ET { + augment ET.foo(this.id, [({int augmented}) r]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(this.id, [({int augmented}) r = (augmented: 0)]) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart new file mode 100644 index 0000000000..851ef38ef3 --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t18.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as a named parameter a record +/// with a positional field with the name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C({(int augmented,) r = (0,)}); + C.foo({(int augmented,) r = (0,)}); +} + +augment class C { + augment C({(int augmented,) r}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo({(int augmented,) r}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar({(int augmented,) r = (0,)}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(), a1.foo(); + const E({(int augmented,) r = (0,)}); + const E.foo({(int augmented,) r = (0,)}); +} + +augment enum E { + a2.bar(); + augment const E({(int augmented,) r}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo({(int augmented,) r}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar({(int augmented,) r = (0,)}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + ET.foo(this.id, {(int augmented,) r = (0,)}); +} + +augment extension type ET { + augment ET.foo(this.id, {(int augmented,) r}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(this.id, {(int augmented,) r = (0,)}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart new file mode 100644 index 0000000000..03d5efa54a --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t19.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as a named parameter a record +/// with a named field with the name `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class C { + C({({int augmented}) r = (augmented: 0)}); + C.foo({({int augmented}) r = (augmented: 0)}); +} + +augment class C { + augment C({({int augmented}) r}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo({({int augmented}) r}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar({({int augmented}) r = (augmented: 0)}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(), a1.foo(); + const E({({int augmented}) r = (augmented: 0)}); + const E.foo({({int augmented}) r = (augmented: 0)}); +} + +augment enum E { + a2.bar(); + augment const E({({int augmented}) r}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo({({int augmented}) r}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar({({int augmented}) r = (augmented: 0)}); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(int id) { + ET.foo(this.id, {({int augmented}) r = (augmented: 0)}); +} + +augment extension type ET { + augment ET.foo(this.id, {({int augmented}) r}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(this.id, {({int augmented}) r = (augmented: 0)}) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart new file mode 100644 index 0000000000..5315079aaa --- /dev/null +++ b/LanguageFeatures/Augmentation-libraries/augmented_expression_A11_t20.dart @@ -0,0 +1,87 @@ +// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/// @assertion The exact result of an `augmented` expression depends on what is +/// being augmented, but it generally follows the same rules as any normal +/// identifier: +/// ... +/// - Augmenting non-redirecting generative constructors: Unlike other +/// functions, `augmented` has no special meaning in non-redirecting +/// generative constructors. It is still a reserved word inside the body of +/// these constructors, since they are within the scope of an augmenting +/// declaration. +/// +/// @description Checks that it is a compile-time error for an augmenting +/// non-redirecting generative constructor to have as a parameter of a type +/// whose name is `augmented`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=macros + +class augmented {} + +class C { + C(augmented x); + C.foo(augmented x); +} + +augment class C { + augment C(augmented x) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment C.foo(augmented x) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + C.bar(augmented x) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +enum E { + a0(null), a1.foo(null); + const E(augmented? _); + const E.foo(augmented? _); +} + +augment enum E { + a2.bar(null); + augment const E(augmented? _); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment const E.foo(augmented? _); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const E.bar(augmented? _); +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +extension type ET(augmented id) {} + +augment extension type ET { + augment ET.new(augmented id) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + augment ET.foo(this.id, augmented id) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET.bar(this.id, augmented x) {} +// ^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} + +main() { + print(C); + print(E); + print(ET); +} diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart index c0ea8dc60a..9f67c23aaa 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03.dart @@ -9,7 +9,7 @@ /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. /// -/// @description Checks that `augmented(arguments)` in the body of augmenting +/// @description Checks that `augmented(arguments)` in the body of an augmenting /// non-redirecting factory constructor calls the introductory constructor with /// `arguments` as the actual arguments. /// @author sgrekhov22@gmail.com diff --git a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart index 484026e854..626d6f7cc7 100644 --- a/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart +++ b/LanguageFeatures/Augmentation-libraries/augmenting_constructors_A16_t03_lib.dart @@ -9,7 +9,7 @@ /// (if present), and it may invoke the augmented body by calling /// `augmented(arguments)`. /// -/// @description Checks that `augmented(arguments)` in the body of augmenting +/// @description Checks that `augmented(arguments)` in the body of an augmenting /// non-redirecting factory constructor calls the introductory constructor with /// `arguments` as the actual arguments. /// @author sgrekhov22@gmail.com