diff --git a/LanguageFeatures/Primary-constructors/static_processing_A11_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A11_t01.dart index 72702a2088..ec7c1801f1 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A11_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A11_t01.dart @@ -2,15 +2,13 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// /// Where no processing is mentioned below, `D2` is identical to `D`. Changes /// occur as follows: @@ -23,7 +21,9 @@ /// the superinterfaces of `D` exists and has return type `T`, the parameter /// `p` has declared type `T`. If no such getter exists, but a setter with the /// same basename exists, with a formal parameter whose type is `T`, the -/// parameter `p` has declared type `T`. +/// parameter `p` has declared type `T`. In other words, an instance variable +/// introduced by a declaring parameter is subject to override inference, just +/// like an explicitly declared instance variable. /// /// @description Check that if the combined member signature for a getter with /// the same name as `p` from the superinterfaces of `D` exists, and has return diff --git a/LanguageFeatures/Primary-constructors/static_processing_A11_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A11_t02.dart index d56af1ac66..9656b732bf 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A11_t02.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A11_t02.dart @@ -2,15 +2,13 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// /// Where no processing is mentioned below, `D2` is identical to `D`. Changes /// occur as follows: @@ -23,7 +21,9 @@ /// the superinterfaces of `D` exists and has return type `T`, the parameter /// `p` has declared type `T`. If no such getter exists, but a setter with the /// same basename exists, with a formal parameter whose type is `T`, the -/// parameter `p` has declared type `T`. +/// parameter `p` has declared type `T`. In other words, an instance variable +/// introduced by a declaring parameter is subject to override inference, just +/// like an explicitly declared instance variable. /// /// @description Check that if the combined member signature for a setter with /// the same basename as `p` from the superinterfaces of `D` exists, and has a diff --git a/LanguageFeatures/Primary-constructors/static_processing_A12_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A12_t01.dart index 9c9d38e4e3..7797c8bdd8 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A12_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A12_t01.dart @@ -2,15 +2,13 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// /// Where no processing is mentioned below, `D2` is identical to `D`. Changes /// occur as follows: @@ -22,7 +20,7 @@ /// ... /// - otherwise, if `p` is optional and has a default value whose static type in /// the empty context is a type `T` which is not `Null` then `p` has declared -/// type `T`. When `T` is `Null`, `p` has declared type `Object?`. +/// type `T`. When `T` is `Null`, `p` instead has declared type `Object?`. /// /// @description Check that if `p` does not have a declared type, but it does /// have a default value whose static type is `T` which is not `Null` then `p` @@ -45,6 +43,42 @@ class C5({var x = 5 as Object}); class C6({var x = 6 as dynamic}); +extension type ET1([final x = 1]); + +extension type ET2([final x = 2 as num]); + +extension type ET3([final x = 3 as dynamic]); + +extension type ET4({final x = 4}); + +extension type ET5({final x = 5 as Object}); + +extension type ET6({final x = 6 as dynamic}); + +enum const E1([final x = 1]) { + e0; +} + +enum const E2([final x = 2 as num]) { + e0; +} + +enum const E3([final x = 3 as dynamic]) { + e0; +} + +enum const E4({final x = 4}) { + e0; +} + +enum const E5({final x = 5 as Object}) { + e0; +} + +enum const E6({final x = 6 as dynamic}) { + e0; +} + main() { C1().x.expectStaticType>(); C2().x.expectStaticType>(); @@ -56,4 +90,26 @@ main() { try { C6().x.checkDynamic; } catch (_) {} + + ET1().x.expectStaticType>(); + ET2().x.expectStaticType>(); + try { + ET3().x.checkDynamic; + } catch (_) {} + ET4().x.expectStaticType>(); + ET5().x.expectStaticType>(); + try { + ET6().x.checkDynamic; + } catch (_) {} + + E1.e0.x.expectStaticType>(); + E2.e0.x.expectStaticType>(); + try { + E3.e0.x.checkDynamic; + } catch (_) {} + E4.e0.x.expectStaticType>(); + E5.e0.x.expectStaticType>(); + try { + E6.e0.x.checkDynamic; + } catch (_) {} } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A12_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A12_t02.dart index fa874087a9..88c1949b67 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A12_t02.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A12_t02.dart @@ -2,15 +2,13 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// /// Where no processing is mentioned below, `D2` is identical to `D`. Changes /// occur as follows: @@ -22,7 +20,7 @@ /// ... /// - otherwise, if `p` is optional and has a default value whose static type in /// the empty context is a type `T` which is not `Null` then `p` has declared -/// type `T`. When `T` is `Null`, `p` has declared type `Object?`. +/// type `T`. When `T` is `Null`, `p` instead has declared type `Object?`. /// /// @description Check that if `p` does not have a declared type, but it does /// have a default value whose static type is `Null` then `p` has the declared @@ -41,9 +39,27 @@ class C3({final x = null}); class C4({var x = null}); +extension type ET1([final x = null]); + +extension type ET2({final x = null}); + +enum const E1([final x = null]) { + e0; +} + +enum const E2({final x = null}) { + e0; +} + main() { C1().x.expectStaticType>(); C2().x.expectStaticType>(); C3().x.expectStaticType>(); C4().x.expectStaticType>(); + + ET1().x.expectStaticType>(); + ET2().x.expectStaticType>(); + + E1.e0.x.expectStaticType>(); + E2.e0.x.expectStaticType>(); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A12_t03.dart b/LanguageFeatures/Primary-constructors/static_processing_A12_t03.dart index 30bb51ed58..17dfe11e66 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A12_t03.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A12_t03.dart @@ -2,15 +2,13 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// /// Where no processing is mentioned below, `D2` is identical to `D`. Changes /// occur as follows: @@ -37,11 +35,23 @@ class C2(final x, [final y]); class C3(final x, {final y}); -class C4(var x, {var x}); +class C4(var x, {var y}); class C5(final x, {required final y}); -class C6(var x, {required var x}); +class C6(var x, {required var y}); + +extension type ET1([final x]); + +extension type ET2({final x}); + +enum const E1([final x]) { + e0; +} + +enum const E2({final x}) { + e0; +} main() { C1(1).x.expectStaticType>(); @@ -56,4 +66,10 @@ main() { C5(5, y: 5).y.expectStaticType>(); C6(6, y: 6).x.expectStaticType>(); C6(6, y: 6).y.expectStaticType>(); + + ET1().x.expectStaticType>(); + ET2().x.expectStaticType>(); + + E1.e0.x.expectStaticType>(); + E2.e0.x.expectStaticType>(); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A12_t04.dart b/LanguageFeatures/Primary-constructors/static_processing_A12_t04.dart index d4b54fea22..c933a936bf 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A12_t04.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A12_t04.dart @@ -2,15 +2,13 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// /// Where no processing is mentioned below, `D2` is identical to `D`. Changes /// occur as follows: @@ -40,12 +38,24 @@ class C4([final x = null]); class C5(final x, {final y}); -class C6(var x, {var x}); +class C6(var x, {var y}); class C7({final x = null}); class C8({var x = null}); +extension type ET1([final x]); + +extension type ET2({final x}); + +enum const E1([final x]) { + e0; +} + +enum const E2({final x}) { + e0; +} + main() { C1(1).x.checkDynamic; // ^^^^^^^^^^^^ @@ -94,5 +104,23 @@ main() { C8().x.checkDynamic; // ^^^^^^^^^^^^ // [analyzer] unspecified +// [cfe] unspecified + + ET1().x.checkDynamic; +// ^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + ET2().x.checkDynamic; +// ^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + + E1.e0.x.checkDynamic; +// ^^^^^^^^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + E2.e0.x.checkDynamic; +// ^^^^^^^^^^^^ +// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A13_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A13_t01.dart index 9f51871a4b..819a2d6d58 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A13_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A13_t01.dart @@ -2,24 +2,19 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. -/// -/// Where no processing is mentioned below, `D2` is identical to `D`. Changes -/// occur as follows: +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// ... /// The current scope of the formal parameter list of the declaring constructor /// in `D` is the body scope of the class. /// /// @description Check that the current scope of the formal parameter list of -/// the declaring constructor is the body scope of the class. +/// the primary constructor is the body scope of the class. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors @@ -34,16 +29,6 @@ class C2({@m var int v = m}) { static const int m = 2; } -class C3 { - this([@m var int v = m]); - static const int m = 3; -} - -class C4 { - this({@m final int v = m}); - static const int m = 4; -} - extension type ET1([@m final int v = m]) { static const int m = 1; } @@ -52,16 +37,6 @@ extension type ET2({@m int v = m}) { static const int m = 2; } -extension type ET3 { - this([@m final int v = m]); - static const int m = 3; -} - -extension type ET4 { - this({@m final int v = m}); - static const int m = 4; -} - enum E1([@m final int v = m]) { e0(0), e1; static const int m = 1; @@ -72,43 +47,19 @@ enum E2({@m final int v = m}) { static const int m = 2; } -enum E3 { - e0(0), e1; - this([@m final int v = m]); - static const int m = 3; -} - -enum E4 { - e0(v: 0), e1; - this({@m final int v = m}); - static const int m = 4; -} - main() { Expect.equals(1, C1().v); Expect.equals(-1, C1(-1).v); Expect.equals(2, C2().v); Expect.equals(-2, C2(v: -2).v); - Expect.equals(3, C3().v); - Expect.equals(-3, C3(-3).v); - Expect.equals(4, C4().v); - Expect.equals(-4, C4(v: -4).v); Expect.equals(1, ET1().v); Expect.equals(-1, ET1(-1).v); Expect.equals(2, ET2().v); Expect.equals(-2, ET2(v: -2).v); - Expect.equals(3, ET3().v); - Expect.equals(-3, ET3(-3).v); - Expect.equals(4, ET4().v); - Expect.equals(-4, ET4(v: -4).v); Expect.equals(1, E1.e1.v); Expect.equals(0, E1.e0.v); Expect.equals(2, E2.e1.v); Expect.equals(0, E2.e0.v); - Expect.equals(3, E3.e1.v); - Expect.equals(0, E3.e0.v); - Expect.equals(4, E4.e1.v); - Expect.equals(0, E4.e0.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A14_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A14_t01.dart index 37b832a56c..cec8d8f10a 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A14_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A14_t01.dart @@ -2,73 +2,46 @@ // 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 following applies to both the header and the body form of -/// declaring constructors. -/// -/// The semantics of the declaring constructor is found in the following steps, -/// where `D` is the class, extension type, or enum declaration in the program -/// that includes a declaring constructor, and `D2` is the result of the -/// derivation of the semantics of `D`. The derivation step will delete elements -/// that amount to the declaring constructor; it will add a new constructor `k`; -/// and it will add zero or more instance variable declarations. -/// -/// Where no processing is mentioned below, `D2` is identical to `D`. Changes -/// occur as follows: +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// ... /// Next, `k` has the modifier `const` iff the keyword `const` occurs just /// before the name of `D` or before `this`, or if `D` is an enum declaration. /// -/// @description Check that the declaring constructor is a constant constructor -/// if the keyword `const` occurs just before the name of `D` or before `this`. -/// For an enum declaration the constructor is constant even without the -/// modifier `const`. +/// @description Check that the primary constructor is a constant constructor +/// if the keyword `const` occurs just before the name of `D`. For an enum +/// declaration the constructor is constant even without the modifier `const`. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors import '../../Utils/expect.dart'; -class const C1(final int v); +class const C(final int v); -class C2 { - const this(final int v); -} +mixin class const M(); -extension type const ET1(int v); - -extension type ET2 { - const this(final int v); -} +extension type const ET(int v); enum const E1(final int v) { e0(1); } -enum E2 { +enum E2(final int v) { e0(2); - const this(final int v); -} - -enum E3(final int v) { - e0(3); -} - -enum E4 { - e0(4); - const this(final int v); } main() { - Expect.equals(1, const C1(1).v); - Expect.equals(2, const C1(2).v); - Expect.equals(1, const ET1(1).v); - Expect.equals(2, const ET2(2).v); + Expect.equals(1, const C(1).v); + Expect.equals(1, const ET(1).v); + const m = M(); const c1 = E1.e0; const c2 = E2.e0; - const c3 = E3.e0; - const c4 = E4.e0; Expect.equals(1, c1.v); Expect.equals(2, c2.v); - Expect.equals(3, c3.v); - Expect.equals(4, c4.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A14_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A14_t02.dart new file mode 100644 index 0000000000..877c02c832 --- /dev/null +++ b/LanguageFeatures/Primary-constructors/static_processing_A14_t02.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2025, 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 semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. +/// ... +/// Next, `k` has the modifier `const` iff the keyword `const` occurs just +/// before the name of `D` or before `this`, or if `D` is an enum declaration. +/// +/// @description Check that the primary constructor is not a constant +/// constructor if there is no `const` keyword just before the name of `D`. +/// @author sgrekhov22@gmail.com + +// SharedOptions=--enable-experiment=primary-constructors + +class C(final int v); + +mixin class M(); + +extension type ET(int v); + +main() { + const C(1); +//^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const ET(1); +//^^^^^ +// [analyzer] unspecified +// [cfe] unspecified + const M(); +//^^^^^ +// [analyzer] unspecified +// [cfe] unspecified +} diff --git a/LanguageFeatures/Primary-constructors/static_processing_A15_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A15_t01.dart index 1e48c0f071..3eebdb94bc 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A15_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A15_t01.dart @@ -2,22 +2,22 @@ // 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 semantics of the declaring constructor is found in the -/// following steps, where `D` is the class, extension type, or enum declaration -/// in the program that includes a declaring constructor `k`, and `D2` is the -/// result of the derivation of the semantics of `D`. The derivation step will -/// delete elements that amount to the declaring constructor. Semantically, it -/// will add a new constructor `k2`, and it will add zero or more instance -/// variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// ... -/// Consider the case where `k` is a declaring header constructor. If the name -/// `C` in `D` and the type parameter list, if any, is followed by `.id` where -/// `id` is an identifier then `k2` has the name `C.id`. If it is followed by -/// `.new` then `k2` has the name `C`. If it is not followed by `.` then `k2` -/// has the name `C`. `D2` omits the part derived from `'.' ` -/// that follows the name and type parameter list in `D`, if said part exists. -/// Moreover, `D2` omits the formal parameter list `L` that follows the name, -/// type parameter list, if any, and `.id`, if any. +/// Consider the case where `k` is a primary constructor. If the name `C` in `D` +/// and the type parameter list, if any, is followed by `.id` where `id` is an +/// identifier then `k2` has the name `C.id`. If it is followed by `.new` then +/// `k2` has the name `C`. If it is not followed by `.` then `k2` has the name +/// `C`. `D2` omits the part derived from `'.' ` that follows +/// the name and type parameter list in `D`, if said part exists. Moreover, `D2` +/// omits the formal parameter list `L` that follows the name, type parameter +/// list, if any, and `.id`, if any. /// /// @description Check that if the name `C` and the type parameter list is /// followed by `.id` then the name of the constructor is `C.id`. @@ -29,7 +29,13 @@ import '../../Utils/expect.dart'; class C1.id(var int v); -class C2.id(var int v); +class C2.id(final int v); + +mixin class M1.id(); + +mixin class M2.id(); + +class C2.id(final int v); extension type ET1.id(int v); @@ -46,6 +52,8 @@ enum E2.id(final int v) { main() { Expect.isTrue(C1.id is C1 Function(int v)); Expect.isTrue(C2.id is C2 Function(int v)); + Expect.isTrue(M1.id is M1 Function()); + Expect.isTrue(M2.id is M2 Function()); Expect.isTrue(ET1.id is ET1 Function(int v)); Expect.isTrue(ET2.id is ET2 Function(int v)); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A15_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A15_t02.dart index 2be8b5cd65..9fff5df24e 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A15_t02.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A15_t02.dart @@ -2,22 +2,22 @@ // 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 semantics of the declaring constructor is found in the -/// following steps, where `D` is the class, extension type, or enum declaration -/// in the program that includes a declaring constructor `k`, and `D2` is the -/// result of the derivation of the semantics of `D`. The derivation step will -/// delete elements that amount to the declaring constructor. Semantically, it -/// will add a new constructor `k2`, and it will add zero or more instance -/// variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// ... -/// Consider the case where `k` is a declaring header constructor. If the name -/// `C` in `D` and the type parameter list, if any, is followed by `.id` where -/// `id` is an identifier then `k2` has the name `C.id`. If it is followed by -/// `.new` then `k2` has the name `C`. If it is not followed by `.` then `k2` -/// has the name `C`. `D2` omits the part derived from `'.' ` -/// that follows the name and type parameter list in `D`, if said part exists. -/// Moreover, `D2` omits the formal parameter list `L` that follows the name, -/// type parameter list, if any, and `.id`, if any. +/// Consider the case where `k` is a primary constructor. If the name `C` in `D` +/// and the type parameter list, if any, is followed by `.id` where `id` is an +/// identifier then `k2` has the name `C.id`. If it is followed by `.new` then +/// `k2` has the name `C`. If it is not followed by `.` then `k2` has the name +/// `C`. `D2` omits the part derived from `'.' ` that follows +/// the name and type parameter list in `D`, if said part exists. Moreover, `D2` +/// omits the formal parameter list `L` that follows the name, type parameter +/// list, if any, and `.id`, if any. /// /// @description Check that if the name `C` and the type parameter list is /// followed by `.new` then the name of the constructor is `C`. @@ -27,7 +27,11 @@ class C1.new(var int v); -class C2.new(var int v); +class C2.new(final int v); + +mixin class M1.new(); + +mixin class M2.new(); extension type ET1.new(int v); @@ -46,6 +50,8 @@ main() { // the name of the constructor is `C1`. new C1(1); new C2(2); + new M1(); + new M2(); new ET1(1); new ET2(2); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A15_t03.dart b/LanguageFeatures/Primary-constructors/static_processing_A15_t03.dart index 0e51477324..c52b0af9c4 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A15_t03.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A15_t03.dart @@ -2,22 +2,22 @@ // 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 semantics of the declaring constructor is found in the -/// following steps, where `D` is the class, extension type, or enum declaration -/// in the program that includes a declaring constructor `k`, and `D2` is the -/// result of the derivation of the semantics of `D`. The derivation step will -/// delete elements that amount to the declaring constructor. Semantically, it -/// will add a new constructor `k2`, and it will add zero or more instance -/// variable declarations. +/// @assertion The semantics of the primary constructor is found in the +/// following steps, where `D` is the class, mixin class, extension type, or +/// enum declaration in the program that includes a primary constructor `k`, and +/// `D2` is the result of the derivation of the semantics of `D`. The derivation +/// step will delete elements that amount to the primary constructor. +/// Semantically, it will add a new constructor `k2`, and it will add zero or +/// more instance variable declarations. /// ... -/// Consider the case where `k` is a declaring header constructor. If the name -/// `C` in `D` and the type parameter list, if any, is followed by `.id` where -/// `id` is an identifier then `k2` has the name `C.id`. If it is followed by -/// `.new` then `k2` has the name `C`. If it is not followed by `.` then `k2` -/// has the name `C`. `D2` omits the part derived from `'.' ` -/// that follows the name and type parameter list in `D`, if said part exists. -/// Moreover, `D2` omits the formal parameter list `L` that follows the name, -/// type parameter list, if any, and `.id`, if any. +/// Consider the case where `k` is a primary constructor. If the name `C` in `D` +/// and the type parameter list, if any, is followed by `.id` where `id` is an +/// identifier then `k2` has the name `C.id`. If it is followed by `.new` then +/// `k2` has the name `C`. If it is not followed by `.` then `k2` has the name +/// `C`. `D2` omits the part derived from `'.' ` that follows +/// the name and type parameter list in `D`, if said part exists. Moreover, `D2` +/// omits the formal parameter list `L` that follows the name, type parameter +/// list, if any, and `.id`, if any. /// /// @description Check that if the name `C` and the type parameter list is not /// followed by `.` then the name of the constructor is `C`. @@ -29,6 +29,10 @@ class C1(var int v); class C2(var int v); +mixin class M1(); + +mixin class M2(); + extension type ET1(int v); extension type ET2(int v); @@ -46,6 +50,8 @@ main() { // the name of the constructor is `C1`. new C1(1); new C2(2); + new M1(); + new M2(); new ET1(1); new ET2(2); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A16_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A16_t01.dart deleted file mode 100644 index d5cafdb265..0000000000 --- a/LanguageFeatures/Primary-constructors/static_processing_A16_t01.dart +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2025, 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 semantics of the declaring constructor is found in the -/// following steps, where `D` is the class, extension type, or enum declaration -/// in the program that includes a declaring constructor `k`, and `D2` is the -/// result of the derivation of the semantics of `D`. The derivation step will -/// delete elements that amount to the declaring constructor. Semantically, it -/// will add a new constructor `k2`, and it will add zero or more instance -/// variable declarations. -/// ... -/// Otherwise, `D` is a declaring body constructor. If the reserved word `this` -/// is followed by `.id` where `id` is an identifier then `k2` has the name -/// `C.id`. If it is followed by `.new` then `k2` has the name `C`. If it is not -/// followed by `.` then `k2` has the name `C`. -/// -/// @description Check that if the reserved word `this` is followed by `.id` -/// then the name of the constructor is `C.id`. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=primary-constructors - -import '../../Utils/expect.dart'; - -class C1 { - this.id(var int v); -} - -class C2 { - this.id(var int v); -} - -extension type ET1 { - this.id(int v); -} - -extension type ET2 { - this.id(int v); -} - -enum E1 { - e0.id(1); - const this.id(final int v); -} - -enum E2 { - e0.id(1); - const this.id(final int v); -} - -main() { - Expect.isTrue(C1.id is C1 Function(int v)); - Expect.isTrue(C2.id is C2 Function(int v)); - Expect.isTrue(ET1.id is ET1 Function(int v)); - Expect.isTrue(ET2.id is ET2 Function(int v)); -} diff --git a/LanguageFeatures/Primary-constructors/static_processing_A16_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A16_t02.dart deleted file mode 100644 index 88f4078bea..0000000000 --- a/LanguageFeatures/Primary-constructors/static_processing_A16_t02.dart +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2025, 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 semantics of the declaring constructor is found in the -/// following steps, where `D` is the class, extension type, or enum declaration -/// in the program that includes a declaring constructor `k`, and `D2` is the -/// result of the derivation of the semantics of `D`. The derivation step will -/// delete elements that amount to the declaring constructor. Semantically, it -/// will add a new constructor `k2`, and it will add zero or more instance -/// variable declarations. -/// ... -/// Otherwise, `D` is a declaring body constructor. If the reserved word `this` -/// is followed by `.id` where `id` is an identifier then `k2` has the name -/// `C.id`. If it is followed by `.new` then `k2` has the name `C`. If it is not -/// followed by `.` then `k2` has the name `C`. -/// -/// @description Check that if the reserved word `this` is followed by `.new` -/// then the name of the constructor is `C`. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=primary-constructors - -class C1 { - this.new(var int v); -} - -class C2 { - this.new(var int v); -} - -extension type ET1 { - this.new(int v); -} - -extension type ET2 { - this.new(int v); -} - -enum E1 { - e0(1); - const this.new(final int v); -} - -enum E2 { - e0(1); - const this.new(final int v); -} - -main() { - // Only a constructor can be invoked with the `new` keyword. This proves that - // the name of the constructor is `C1`. - new C1(1); - new C2(2); - new ET1(1); - new ET2(2); -} diff --git a/LanguageFeatures/Primary-constructors/static_processing_A16_t03.dart b/LanguageFeatures/Primary-constructors/static_processing_A16_t03.dart deleted file mode 100644 index dda8bc4bc8..0000000000 --- a/LanguageFeatures/Primary-constructors/static_processing_A16_t03.dart +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2025, 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 semantics of the declaring constructor is found in the -/// following steps, where `D` is the class, extension type, or enum declaration -/// in the program that includes a declaring constructor `k`, and `D2` is the -/// result of the derivation of the semantics of `D`. The derivation step will -/// delete elements that amount to the declaring constructor. Semantically, it -/// will add a new constructor `k2`, and it will add zero or more instance -/// variable declarations. -/// ... -/// Otherwise, `D` is a declaring body constructor. If the reserved word `this` -/// is followed by `.id` where `id` is an identifier then `k2` has the name -/// `C.id`. If it is followed by `.new` then `k2` has the name `C`. If it is not -/// followed by `.` then `k2` has the name `C`. -/// -/// @description Check that if the reserved word `this` is not followed by `.` -/// then the name of the constructor is `C`. -/// @author sgrekhov22@gmail.com - -// SharedOptions=--enable-experiment=primary-constructors - -class C1 { - this(var int v); -} - -class C2 { - this(var int v); -} - -extension type ET1 { - this(int v); -} - -extension type ET2 { - this(int v); -} - -enum E1 { - e0(1); - const this(final int v); -} - -enum E2 { - e0(1); - const this(final int v); -} - -main() { - // Only a constructor can be invoked with the `new` keyword. This proves that - // the name of the constructor is `C1`. - new C1(1); - new C2(2); - new ET1(1); - new ET2(2); -}