From 25e4a752c876daed44c615256e4dc9c12528dc4d Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Thu, 20 Nov 2025 15:04:42 +0200 Subject: [PATCH 1/2] #3315. Update tests for formal parameters. Part 4. --- .../static_processing_A21_t01.dart | 66 +++---------- .../static_processing_A21_t02.dart | 80 +++------------ .../static_processing_A21_t03.dart | 80 +++------------ .../static_processing_A21_t04.dart | 66 +++---------- .../static_processing_A21_t05.dart | 42 +++----- .../static_processing_A21_t06.dart | 42 +++----- .../static_processing_A21_t07.dart | 42 +++----- .../static_processing_A21_t08.dart | 42 +++----- .../static_processing_A21_t09.dart | 78 +++------------ .../static_processing_A21_t10.dart | 78 +++------------ .../static_processing_A21_t11.dart | 78 +++------------ .../static_processing_A21_t12.dart | 78 +++------------ .../static_processing_A22_t01.dart | 97 +++++------------- .../static_processing_A22_t02.dart | 98 +++++-------------- .../static_processing_A22_t03.dart | 98 +++++-------------- .../static_processing_A22_t04.dart | 98 +++++-------------- .../static_processing_A22_t05.dart | 97 +++++------------- .../static_processing_A22_t06.dart | 96 ++++-------------- .../static_processing_A22_t07.dart | 98 +++++-------------- .../static_processing_A22_t08.dart | 98 +++++-------------- 20 files changed, 345 insertions(+), 1207 deletions(-) diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t01.dart index 9342fdb39f..06659b73a6 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t01.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -35,26 +39,10 @@ class C1(var String v1, final T v2); class C2(final String v1, var int v2); -class C3 { - this(final String v1, var T v2); -} - -class C4 { - this(var String v1, final int v2); -} - extension type ET1(final T v); extension type ET2(final String v); -extension type ET3 { - this(final T t); -} - -extension type ET4 { - this(final String v); -} - enum E1(final T v) { e0("E1"); } @@ -63,16 +51,6 @@ enum E2(final String v) { e0("E2"); } -enum E3 { - e0("E3"); - const this(final T v); -} - -enum E4 { - e0("E4"); - const this(final String v); -} - main() { var c1 = C1("C1", 2); Expect.equals("C1", c1.v1); @@ -82,28 +60,12 @@ main() { Expect.equals("C2", c2.v1); Expect.equals(2, c2.v2); - var c3 = C3("C3", 2); - Expect.equals("C3", c3.v1); - Expect.equals(2, c3.v2); - - var c4 = C4("C4", 2); - Expect.equals("C4", c4.v1); - Expect.equals(2, c4.v2); - var et1 = ET1("ET1"); Expect.equals("ET1", et1.v); var et2 = ET2("ET2"); Expect.equals("ET2", et2.v); - var et3 = ET3("ET3"); - Expect.equals("ET3", et3.v); - - var et4 = ET4("ET4"); - Expect.equals("ET4", et4.v); - Expect.equals("E1", E1.e0.v); Expect.equals("E2", E2.e0.v); - Expect.equals("E3", E3.e0.v); - Expect.equals("E4", E4.e0.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t02.dart index 71eb6f4047..2c294b6902 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t02.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t02.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -35,26 +39,10 @@ class C1([var String v1 = "default", final T? v2]); class C2([final String v1 = "default", var int v2 = 0]); -class C3 { - this([final String v1 = "default", var T? v2]); -} - -class C4 { - this([var String v1 = "default", final int v2 = 0]); -} - extension type ET1([final T? v]); extension type ET2([String v = "default"]); -extension type ET3 { - this([final T? t]); -} - -extension type ET4 { - this([final String v = "default"]); -} - enum E1([final T? v]) { e0("E1"), e1; } @@ -63,16 +51,6 @@ enum E2([final String v = "default"]) { e0("E2"), e1; } -enum E3 { - e0("E3"), e1; - const this([final T? v]); -} - -enum E4 { - e0("E4"), e1; - const this([final String v = "default"]); -} - main() { var c1 = C1("C1", 2); Expect.equals("C1", c1.v1); @@ -84,24 +62,10 @@ main() { var c2 = C2("C2", 2); Expect.equals("C2", c2.v1); Expect.equals(2, c2.v2); - c2 = C2(); + c2 = C2(); Expect.equals("default", c2.v1); Expect.equals(0, c2.v2); - var c3 = C3("C3", 2); - Expect.equals("C3", c3.v1); - Expect.equals(2, c3.v2); - c3 = C3(); - Expect.equals("default", c3.v1); - Expect.isNull(c3.v2); - - var c4 = C4("C4", 2); - Expect.equals("C4", c4.v1); - Expect.equals(2, c4.v2); - c4 = C4(); - Expect.equals("default", c4.v1); - Expect.equals(0, c4.v2); - var et1 = ET1("ET1"); Expect.equals("ET1", et1.v); et1 = ET1(); @@ -112,22 +76,8 @@ main() { et2 = ET2(); Expect.equals("default", et2.v); - var et3 = ET3("ET3"); - Expect.equals("ET3", et3.v); - et3 = ET1(); - Expect.isNull(et3.v); - - var et4 = ET4("ET4"); - Expect.equals("ET4", et4.v); - et4 = ET4(); - Expect.equals("default", et4.v); - Expect.equals("E1", E1.e0.v); Expect.isNull(E1.e1.v); Expect.equals("E2", E2.e0.v); Expect.equals("default", E2.e1.v); - Expect.equals("E3", E3.e0.v); - Expect.isNull(E3.e1.v); - Expect.equals("E4", E4.e0.v); - Expect.equals("default", E4.e1.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t03.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t03.dart index e8abe9f45e..12bba3955f 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t03.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t03.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -35,26 +39,10 @@ class C1({var String v1 = "default", final T? v2}); class C2({final String v1 = "default", var int v2 = 0}); -class C3 { - this({final String v1 = "default", var T? v2}); -} - -class C4 { - this({var String v1 = "default", final int v2 = 0}); -} - extension type ET1({final T? v}); extension type ET2({String v = "default"}); -extension type ET3 { - this({final T? t}); -} - -extension type ET4 { - this({final String v = "default"}); -} - enum E1({final T? v}) { e0(v: "E1"), e1; } @@ -63,16 +51,6 @@ enum E2({final String v = "default"}) { e0(v: "E2"), e1; } -enum E3 { - e0(v: "E3"), e1; - const this({final T? v}); -} - -enum E4 { - e0(v: "E4"), e1; - const this({final String v = "default"}); -} - main() { var c1 = C1(v1: "C1", v2: 2); Expect.equals("C1", c1.v1); @@ -84,24 +62,10 @@ main() { var c2 = C2(v1: "C2", v2: 2); Expect.equals("C2", c2.v1); Expect.equals(2, c2.v2); - c2 = C2(); + c2 = C2(); Expect.equals("default", c2.v1); Expect.equals(0, c2.v2); - var c3 = C3(v1: "C3", v2: 2); - Expect.equals("C3", c3.v1); - Expect.equals(2, c3.v2); - c3 = C3(); - Expect.equals("default", c3.v1); - Expect.isNull(c3.v2); - - var c4 = C4(v1: "C4", v2: 2); - Expect.equals("C4", c4.v1); - Expect.equals(2, c4.v2); - c4 = C4(); - Expect.equals("default", c4.v1); - Expect.equals(0, c4.v2); - var et1 = ET1(v: "ET1"); Expect.equals("ET1", et1.v); et1 = ET1(); @@ -112,22 +76,8 @@ main() { et2 = ET2(); Expect.equals("default", et2.v); - var et3 = ET3(v: "ET3"); - Expect.equals("ET3", et3.v); - et3 = ET1(); - Expect.isNull(et3.v); - - var et4 = ET4(v: "ET4"); - Expect.equals("ET4", et4.v); - et4 = ET4(); - Expect.equals("default", et4.v); - Expect.equals("E1", E1.e0.v); Expect.isNull(E1.e1.v); Expect.equals("E2", E2.e0.v); Expect.equals("default", E2.e1.v); - Expect.equals("E3", E3.e0.v); - Expect.isNull(E3.e1.v); - Expect.equals("E4", E4.e0.v); - Expect.equals("default", E4.e1.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t04.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t04.dart index d2e4fc1173..0c2effde44 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t04.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t04.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -35,26 +39,10 @@ class C1({required var String v1, required final T v2}); class C2({required final String v1, required var int v2}); -class C3 { - this({required final String v1, required var T v2}); -} - -class C4 { - this({required var String v1, required final int v2}); -} - extension type ET1({required final T v}); extension type ET2({required String v}); -extension type ET3 { - this({required final T t}); -} - -extension type ET4 { - this({required final String v}); -} - enum E1({required final T v}) { e0(v: "E1"); } @@ -63,16 +51,6 @@ enum E2({required final String v}) { e0(v: "E2"); } -enum E3 { - e0(v: "E3"); - const this({required final T v}); -} - -enum E4 { - e0(v: "E4"); - const this({required final String v}); -} - main() { var c1 = C1(v1: "C1", v2: 2); Expect.equals("C1", c1.v1); @@ -82,28 +60,12 @@ main() { Expect.equals("C2", c2.v1); Expect.equals(2, c2.v2); - var c3 = C3(v1: "C3", v2: 2); - Expect.equals("C3", c3.v1); - Expect.equals(2, c3.v2); - - var c4 = C4(v1: "C4", v2: 2); - Expect.equals("C4", c4.v1); - Expect.equals(2, c4.v2); - var et1 = ET1(v: "ET1"); Expect.equals("ET1", et1.v); var et2 = ET2(v: "ET2"); Expect.equals("ET2", et2.v); - var et3 = ET3(v: "ET3"); - Expect.equals("ET3", et3.v); - - var et4 = ET4(v: "ET4"); - Expect.equals("ET4", et4.v); - Expect.equals("E1", E1.e0.v); Expect.equals("E2", E2.e0.v); - Expect.equals("E3", E3.e0.v); - Expect.equals("E4", E4.e0.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t05.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t05.dart index 4c9e2075ce..56c1f3978b 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t05.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t05.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -34,14 +38,6 @@ class C1(var T v); class C2(var int v); -class C3 { - this(var T v); -} - -class C4 { - this(var int v); -} - main() { var c1 = C1(1); Expect.equals(1, c1.v); @@ -52,14 +48,4 @@ main() { Expect.equals(1, c2.v); c2.v = 2; Expect.equals(2, c2.v); - - var c3 = C3(1); - Expect.equals(1, c3.v); - c3.v = 2; - Expect.equals(2, c3.v); - - var c4 = C4(1); - Expect.equals(1, c4.v); - c4.v = 2; - Expect.equals(2, c4.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t06.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t06.dart index 5233f106fb..8f4859be93 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t06.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t06.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -35,14 +39,6 @@ class C1([var T? v]); class C2([var int v = 0]); -class C3 { - this([var T? v]); -} - -class C4 { - this([var int v = 0]); -} - main() { var c1 = C1(1); Expect.equals(1, c1.v); @@ -53,14 +49,4 @@ main() { Expect.equals(1, c2.v); c2.v = 2; Expect.equals(2, c2.v); - - var c3 = C3(1); - Expect.equals(1, c3.v); - c3.v = 2; - Expect.equals(2, c3.v); - - var c4 = C4(1); - Expect.equals(1, c4.v); - c4.v = 2; - Expect.equals(2, c4.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t07.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t07.dart index fad1a98a1e..fbc0eaa372 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t07.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t07.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -34,14 +38,6 @@ class C1({var T? v}); class C2({var int v = 0}); -class C3 { - this({var T? v}); -} - -class C4 { - this({var int v = 0}); -} - main() { var c1 = C1(v: 1); Expect.equals(1, c1.v); @@ -52,14 +48,4 @@ main() { Expect.equals(1, c2.v); c2.v = 2; Expect.equals(2, c2.v); - - var c3 = C3(v: 1); - Expect.equals(1, c3.v); - c3.v = 2; - Expect.equals(2, c3.v); - - var c4 = C4(v: 1); - Expect.equals(1, c4.v); - c4.v = 2; - Expect.equals(2, c4.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t08.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t08.dart index 2c5785db25..7b5b9901a6 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t08.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t08.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -34,14 +38,6 @@ class C1({required var T v}); class C2({required var int v}); -class C3 { - this({required var T v}); -} - -class C4 { - this({required var int v}); -} - main() { var c1 = C1(v: 1); Expect.equals(1, c1.v); @@ -52,14 +48,4 @@ main() { Expect.equals(1, c2.v); c2.v = 2; Expect.equals(2, c2.v); - - var c3 = C3(v: 1); - Expect.equals(1, c3.v); - c3.v = 2; - Expect.equals(2, c3.v); - - var c4 = C4(v: 1); - Expect.equals(1, c4.v); - c4.v = 2; - Expect.equals(2, c4.v); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t09.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t09.dart index 19bf8eb606..bc5d5f836d 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t09.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t09.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -31,26 +35,10 @@ class C1(final T v); class C2(final String v); -class C3 { - this(final T v); -} - -class C4 { - this(final String v); -} - extension type ET1(final T v); extension type ET2(String v); -extension type ET3 { - this(final T t); -} - -extension type ET4 { - this(final String v); -} - enum E1(final T v) { e0("E1"); } @@ -59,16 +47,6 @@ enum E2(final String v) { e0("E2"); } -enum E3 { - e0("E3"); - const this(final T v); -} - -enum E4 { - e0("E4"); - const this(final String v); -} - main() { C1("C1").v = ""; // ^ @@ -78,16 +56,6 @@ main() { C2("C2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - C3("C3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - C4("C4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified ET1("ET1").v = ""; @@ -98,16 +66,6 @@ main() { ET2("ET2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - ET3("ET3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - ET4("ET4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified E1.e0.v = ""; @@ -117,13 +75,5 @@ main() { E2.e0.v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - E3.e0.v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - E4.e0.v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t10.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t10.dart index 68cce08c77..e0fa1cdf21 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t10.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t10.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -31,26 +35,10 @@ class C1([final T? v]); class C2([final String v = "default"]); -class C3 { - this([final T? v]); -} - -class C4 { - this([final String v = "default"]); -} - extension type ET1([final T? v]); extension type ET2([String v = "default"]); -extension type ET3 { - this([final T? t]); -} - -extension type ET4 { - this([final String v = "default"]); -} - enum E1([final T? v]) { e0("E1"); } @@ -59,16 +47,6 @@ enum E2([final String v = "default"]) { e0("E2"); } -enum E3 { - e0("E3"); - const this([final T? v]); -} - -enum E4 { - e0("E4"); - const this([final String v = "default"]); -} - main() { C1("C1").v = ""; // ^ @@ -78,16 +56,6 @@ main() { C2("C2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - C3("C3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - C4("C4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified ET1("ET1").v = ""; @@ -98,16 +66,6 @@ main() { ET2("ET2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - ET3("ET3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - ET4("ET4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified E1.e0.v = ""; @@ -117,13 +75,5 @@ main() { E2.e0.v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - E3.e0.v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - E4.e0.v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t11.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t11.dart index 3e99102816..c90c7b00a8 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t11.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t11.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -31,26 +35,10 @@ class C1({final T? v}); class C2({final String v = "default"}); -class C3 { - this({final T? v}); -} - -class C4 { - this({final String v = "default"}); -} - extension type ET1({final T? v}); extension type ET2({String v = "default"}); -extension type ET3 { - this({final T? t}); -} - -extension type ET4 { - this({final String v = "default"}); -} - enum E1({final T? v}) { e0(v: "E1"); } @@ -59,16 +47,6 @@ enum E2({final String v = "default"}) { e0(v: "E2"); } -enum E3 { - e0(v: "E3"); - const this({final T? v}); -} - -enum E4 { - e0(v: "E4"); - const this({final String v = "default"}); -} - main() { C1(v: "C1").v = ""; // ^ @@ -78,16 +56,6 @@ main() { C2(v: "C2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - C3(v: "C3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - C4(v: "C4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified ET1(v: "ET1").v = ""; @@ -98,16 +66,6 @@ main() { ET2(v: "ET2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - ET3(v: "ET3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - ET4(v: "ET4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified E1.e0.v = ""; @@ -117,13 +75,5 @@ main() { E2.e0.v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - E3.e0.v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - E4.e0.v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A21_t12.dart b/LanguageFeatures/Primary-constructors/static_processing_A21_t12.dart index 5216443bf4..f3e697b41e 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A21_t12.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A21_t12.dart @@ -2,21 +2,25 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// @@ -31,26 +35,10 @@ class C1({required final T v}); class C2({required final String v}); -class C3 { - this({required final T v}); -} - -class C4 { - this({required final String v}); -} - extension type ET1({required final T v}); extension type ET2({required String v}); -extension type ET3 { - this({required final T t}); -} - -extension type ET4 { - this({required final String v}); -} - enum E1({required final T v}) { e0(v: "E1"); } @@ -59,16 +47,6 @@ enum E2({required final String v}) { e0(v: "E2"); } -enum E3 { - e0(v: "E3"); - const this({required final T v}); -} - -enum E4 { - e0(v: "E4"); - const this({required final String v}); -} - main() { C1(v: "C1").v = ""; // ^ @@ -78,16 +56,6 @@ main() { C2(v: "C2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - C3(v: "C3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - C4(v: "C4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified ET1(v: "ET1").v = ""; @@ -98,16 +66,6 @@ main() { ET2(v: "ET2").v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - - ET3(v: "ET3").v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - - ET4(v: "ET4").v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified E1.e0.v = ""; @@ -117,13 +75,5 @@ main() { E2.e0.v = ""; // ^ // [analyzer] unspecified -// [cfe] unspecified - E3.e0.v = ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified - E4.e0.v = ""; -// ^ -// [analyzer] unspecified // [cfe] unspecified } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t01.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t01.dart index b2b1e03147..078cb41afd 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t01.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t01.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains an instance -/// member named `p`. Test mandatory parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains an instance member named `p`. +/// Test mandatory parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1(var String v1, final T v2, var bool v3) { - String get v1 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this(final String v1, var T v2, final bool v3); +class C(var String v1, final T v2, var bool v3) { String get v1 => ""; // ^^ // [analyzer] unspecified @@ -73,25 +61,7 @@ extension type ET2(String v) { // [cfe] unspecified } -extension type ET3 { - this(final T v); - - void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this(final String v); - - String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1(final T v1, final String v2, final bool v3) { +enum E(final T v1, final String v2, final bool v3) { e0(1, "E1", true); final T v1; @@ -108,32 +78,9 @@ enum E1(final T v1, final String v2, final bool v3) { // [cfe] unspecified } -enum E2 { - e0(1, "E1", true); - - this(final T v1, final String v2, final bool v3); - - final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t02.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t02.dart index 951088a1aa..68d05f74d5 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t02.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t02.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains an instance -/// member named `p`. Test optional positional parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains an instance member named `p`. +/// Test optional positional parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1([var String v1 = "", final T? v2, var bool v3 = true]) { - String get v1 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this([var String v1 = "", final T? v2, var bool v3 = true]); +class C([var String v1 = "", final T? v2, var bool v3 = true]) { String get v1 => ""; // ^^ // [analyzer] unspecified @@ -53,7 +41,6 @@ class C2 { // ^^ // [analyzer] unspecified // [cfe] unspecified - void v3() {} // ^^ // [analyzer] unspecified @@ -74,25 +61,7 @@ extension type ET2([String v = ""]) { // [cfe] unspecified } -extension type ET3 { - this([final T? v]); - - void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this([final String v = ""]); - - String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1([final T? v1, final String v2 = "", final bool v3 = true]) { +enum E([final T? v1, final String v2 = "", final bool v3 = true]) { e0(1, "E1", true); final T v1; @@ -109,32 +78,9 @@ enum E1([final T? v1, final String v2 = "", final bool v3 = true]) { // [cfe] unspecified } -enum E2 { - e0(1, "E1", true); - - this([final T? v1, final String v2 = "", final bool v3 = true]); - - final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t03.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t03.dart index 0220e68a93..fe54d3534f 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t03.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t03.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains an instance -/// member named `p`. Test optional named parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains an instance member named `p`. +/// Test optional named parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1({var String v1 = "", final T? v2, var bool v3 = true}) { - String get v1 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this({var String v1 = "", final T? v2, var bool v3 = true}); +class C({var String v1 = "", final T? v2, var bool v3 = true}) { String get v1 => ""; // ^^ // [analyzer] unspecified @@ -53,7 +41,6 @@ class C2 { // ^^ // [analyzer] unspecified // [cfe] unspecified - void v3() {} // ^^ // [analyzer] unspecified @@ -74,25 +61,7 @@ extension type ET2({String v = ""}) { // [cfe] unspecified } -extension type ET3 { - this({final T? v}); - - void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this({final String v = ""}); - - String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1({final T? v1, final String v2 = "", final bool v3 = true}) { +enum E({final T? v1, final String v2 = "", final bool v3 = true}) { e0(); final T v1; @@ -109,32 +78,9 @@ enum E1({final T? v1, final String v2 = "", final bool v3 = true}) { // [cfe] unspecified } -enum E2 { - e0(); - - this({final T? v1, final String v2 = "", final bool v3 = true}); - - final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t04.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t04.dart index 97e5362f65..770f8e55b4 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t04.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t04.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains an instance -/// member named `p`. Test required named parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains an instance member named `p`. +/// Test required named parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1({required var int v1, required final T v2, required var bool v3}) { - int get v1 => 0; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this({required var int v1, required final T v2, required var bool v3}); +class C({required var int v1, required final T v2, required var bool v3}) { int get v1 => 0; // ^^ // [analyzer] unspecified @@ -53,7 +41,6 @@ class C2 { // ^^ // [analyzer] unspecified // [cfe] unspecified - void v3() {} // ^^ // [analyzer] unspecified @@ -74,25 +61,7 @@ extension type ET2({required String v}) { // [cfe] unspecified } -extension type ET3 { - this({required final T v}); - - void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this({required final String v}); - - String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1({ +enum E({ required final T v1, required final String v2, required final bool v3}) { @@ -112,32 +81,9 @@ enum E1({ // [cfe] unspecified } -enum E2 { - e0(); - - this({required final T v1, required final String v2, required final bool v3}); - - final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t05.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t05.dart index 35a2a68980..fab79c04d8 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t05.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t05.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains a static -/// member named `p`. Test mandatory parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains a static member named `p`. Test +/// mandatory parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1(var String v1, final T v2, var bool v3) { - static String get v1 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this(final String v1, var T v2, final bool v3); +class C(var String v1, final T v2, var bool v3) { static String get v1 => ""; // ^^ // [analyzer] unspecified @@ -73,25 +61,7 @@ extension type ET2(String v) { // [cfe] unspecified } -extension type ET3 { - this(final T v); - - static void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this(final String v); - - static String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1(final T v1, final String v2, final bool v3) { +enum E(final T v1, final String v2, final bool v3) { e0(1, "E1", true); static final T v1; @@ -108,32 +78,9 @@ enum E1(final T v1, final String v2, final bool v3) { // [cfe] unspecified } -enum E2 { - e0(1, "E1", true); - - this(final T v1, final String v2, final bool v3); - - static final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart index 6229858d1c..aceec9aad4 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains a static -/// member named `p`. Test optional positional parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains a static member named `p`. Test +/// optional positional parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1([var String v1 = "", final T? v2, var bool v3 = true]) { - static String get v1 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this([final String v1 = "", var T? v2, final bool v3 = true]); +class C([var String v1 = "", final T? v2, var bool v3 = true]) { static String get v1 => ""; // ^^ // [analyzer] unspecified @@ -53,7 +41,6 @@ class C2 { // ^^ // [analyzer] unspecified // [cfe] unspecified - static void v3() {} // ^^ // [analyzer] unspecified @@ -74,24 +61,6 @@ extension type ET2([String v = ""]) { // [cfe] unspecified } -extension type ET3 { - this([final T? v]); - - static void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this([final String v = ""]); - - static String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - enum E1([final T? v1, final String v2 = "", final bool v3 = true]) { e0(1, "E1", true); @@ -109,32 +78,9 @@ enum E1([final T? v1, final String v2 = "", final bool v3 = true]) { // [cfe] unspecified } -enum E2 { - e0(1, "E1", true); - - this([final T? v1, final String v2 = "", final bool v3 = true]); - - static final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t07.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t07.dart index 8060e169ea..165e33789c 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t07.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t07.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains a static -/// member named `p`. Test optional named parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains a static member named `p`. Test +/// optional named parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1({var String v1 = "", final T? v2, var bool v3 = true}) { - static String get v1 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this({final String v1 = "", var T? v2, final bool v3 = true}); +class C({var String v1 = "", final T? v2, var bool v3 = true}) { static String get v1 => ""; // ^^ // [analyzer] unspecified @@ -53,7 +41,6 @@ class C2 { // ^^ // [analyzer] unspecified // [cfe] unspecified - static void v3() {} // ^^ // [analyzer] unspecified @@ -74,25 +61,7 @@ extension type ET2({String v = ""}) { // [cfe] unspecified } -extension type ET3 { - this({final T? v}); - - static void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this({final String v = ""}); - - static String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1({final T? v1, final String v2 = "", final bool v3 = true}) { +enum E({final T? v1, final String v2 = "", final bool v3 = true}) { e0(); static final T v1; @@ -109,32 +78,9 @@ enum E1({final T? v1, final String v2 = "", final bool v3 = true}) { // [cfe] unspecified } -enum E2 { - e0(); - - this({final T? v1, final String v2 = "", final bool v3 = true}); - - static final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t08.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t08.dart index 04424caa37..6825657f61 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t08.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t08.dart @@ -2,49 +2,37 @@ // 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. /// ... -/// Otherwise, a formal parameter (named or positional) of the form` var T p` or +/// The formal parameter list `L2` of `k2` is identical to `L`, except that each +/// formal parameter is processed as follows. +/// ... +/// Otherwise, a formal parameter (named or positional) of the form `var T p` or /// `final T p` where `T` is a type and `p` is an identifier is replaced in `L2` /// by `this.p`, along with its default value, if any. Next, a semantic instance /// variable declaration corresponding to the syntax `T p;` or `final T p;` is /// added to `D2`. It includes the modifier `final` if the parameter in `L` has -/// the modifier `final`, or `D` is an extension type declaration and `k` is a -/// declaring header constructor. In all cases, if `p` has the modifier +/// the modifier `final` and `D` is not an `extension type` declaration; if `D` +/// is an extension type declaration then the name of `p` specifies the name of +/// the representation variable. In all cases, if `p` has the modifier /// `covariant` then this modifier is removed from the parameter in `L2`, and it /// is added to the instance variable declaration named `p`. /// -/// @description Check that it is a compile-time error if a declaring -/// constructor contains a formal parameter of the form `var T p` or -/// `final T p` and the enclosing class/enum/extension type contains a static -/// member named `p`. Test required named parameters. +/// @description Check that it is a compile-time error if a primary constructor +/// contains a formal parameter of the form `var T p` or `final T p` and the +/// enclosing class/enum/extension type contains a static member named `p`. Test +/// required named parameters. /// @author sgrekhov22@gmail.com // SharedOptions=--enable-experiment=primary-constructors -class C1({required var int v1, required final T v2, required var bool v3}) { - static int get v1 => 0; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static T v2; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - -class C2 { - this({required final int v1, required var T v2, required final bool v3}); +class C({required var int v1, required final T v2, required var bool v3}) { static int get v1 => 0; // ^^ // [analyzer] unspecified @@ -53,7 +41,6 @@ class C2 { // ^^ // [analyzer] unspecified // [cfe] unspecified - static void v3() {} // ^^ // [analyzer] unspecified @@ -74,25 +61,7 @@ extension type ET2({required String v}) { // [cfe] unspecified } -extension type ET3 { - this({required final T v}); - - static void v() {} -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -extension type ET4 { - this({required final String v}); - - static String get v => ""; -// ^ -// [analyzer] unspecified -// [cfe] unspecified -} - -enum E1({ +enum E({ required final T v1, required final String v2, required final bool v3}) { @@ -112,32 +81,9 @@ enum E1({ // [cfe] unspecified } -enum E2 { - e0(); - - this({required final T v1, required final String v2, required final bool v3}); - - static final T v1; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static String get v2 => ""; -// ^^ -// [analyzer] unspecified -// [cfe] unspecified - static void v3() {} -// ^^ -// [analyzer] unspecified -// [cfe] unspecified -} - main() { - print(C1); - print(C2); + print(C); print(ET1); print(ET2); - print(ET3); - print(ET4); - print(E1); - print(E2); + print(E); } From 30144bcac7976826ee75a8b4f859bc4c59d4e841 Mon Sep 17 00:00:00 2001 From: sgrekhov Date: Thu, 20 Nov 2025 16:55:38 +0200 Subject: [PATCH 2/2] Fix a typo --- .../Primary-constructors/static_processing_A22_t06.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart b/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart index aceec9aad4..29ef56b62e 100644 --- a/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart +++ b/LanguageFeatures/Primary-constructors/static_processing_A22_t06.dart @@ -61,8 +61,8 @@ extension type ET2([String v = ""]) { // [cfe] unspecified } -enum E1([final T? v1, final String v2 = "", final bool v3 = true]) { - e0(1, "E1", true); +enum E([final T? v1, final String v2 = "", final bool v3 = true]) { + e0(1, "E", true); static final T v1; // ^^