Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension type ET4({required String x}) {
main() {
var et1 = ET1("parameter");
Expect.equals("parameter", et1.x);
if (log.isNotEmpty) {
if (assertStatementsEnabled()) {
Expect.equals("parameter", log);
log = "";
}
Expand All @@ -71,7 +71,7 @@ main() {

var et2 = ET2("parameter");
Expect.equals("parameter", et2.x);
if (log.isNotEmpty) {
if (assertStatementsEnabled()) {
Expect.equals("parameter", log);
log = "";
}
Expand All @@ -80,7 +80,7 @@ main() {

et2 = ET2();
Expect.equals("default", et2.x);
if (log.isNotEmpty) {
if (assertStatementsEnabled()) {
Expect.equals("parameter", log);
log = "";
}
Expand All @@ -89,7 +89,7 @@ main() {

var et3 = ET3(x: "parameter");
Expect.equals("parameter", et3.x);
if (log.isNotEmpty) {
if (assertStatementsEnabled()) {
Expect.equals("parameter", log);
log = "";
}
Expand All @@ -98,7 +98,7 @@ main() {

et3 = ET3();
Expect.equals("default", et3.x);
if (log.isNotEmpty) {
if (assertStatementsEnabled()) {
Expect.equals("parameter", log);
log = "";
}
Expand All @@ -107,7 +107,7 @@ main() {

var et4 = ET4(x: "parameter");
Expect.equals("parameter", et4.x);
if (log.isNotEmpty) {
if (assertStatementsEnabled()) {
Expect.equals("parameter", log);
log = "";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,88 @@
// 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 two formal parameters with the same name.
/// Test declaring vs. initializing formals.
/// @description Check that it is a compile-time error if a primary constructor
/// contains two formal parameters with the same name. Test declaring vs.
/// initializing formals.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=primary-constructors

class C1<T>(var T v, this.v);
// ^^^^^^
// ^
// [analyzer] unspecified
// [cfe] unspecified

class C2 {
this(final String v, [this.v = ""]);
// ^^^^^^
class C2(final String v, [this.v = ""]);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

class C3<T>(final T v, {this.v = ""});
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

class C4 {
this(final String v, {required this.v});
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET1 {
this(final String v, this.v);
// ^^^^^^
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET2<T> {
this(final T? v, [this.v]);
// ^^^^^^
class C4(final String v, {required this.v});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET3 {
this(final String v, {this.v = ""});
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

extension type ET4<T> {
this(final T? v, {required this.v});
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E1<T>(final T v, this.v) {
// ^^^^^^
// ^
// [analyzer] unspecified
// [cfe] unspecified
e0<int>(1, 2);
}

enum E2 {
e0("1", "2");
this(final String v, [this.v = ""]);
// ^^^^^^
enum E2(final String v, [this.v = ""]) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
e0("1", "2");
}

enum E3<T>(final T? v, {this.v}) {
// ^^^^^^
// ^
// [analyzer] unspecified
// [cfe] unspecified
e0<int>(1);
}

enum E4 {
e0("1", v: "2");
this(final String v, {required this.v});
// ^^^^^^
enum E4(final String v, {required this.v}) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
e0("1", v: "2");
}

main() {
print(C1);
print(C2);
print(C3);
print(C4);
print(ET1);
print(ET2);
print(ET3);
print(ET4);
print(E1);
print(E2);
print(E3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@
// 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 two formal parameters with the same name.
/// Test declaring vs. super parameters.
/// @description Check that it is a compile-time error if a primary constructor
/// contains two formal parameters with the same name. Test declaring vs. super
/// parameters.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=primary-constructors
Expand All @@ -33,28 +37,24 @@ class A<T> {
}

class C1<T>(@override var T? v, super.v) extends A<T>;
// ^^^^^^^
// ^
// [analyzer] unspecified
// [cfe] unspecified

class C2 extends A<String> {
this(@override final String v, [super.v = ""]);
// ^^^^^^^
class C2(@override final String v, [super.v = ""]) extends A<String>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

class C3<T>(final T? v, {super.v}) extends A<T>;
// ^^^^^^^
// ^
// [analyzer] unspecified
// [cfe] unspecified

class C4 extends A<String>{
this(final String v, {required super.v});
// ^^^^^^^
class C4(final String v, {required super.v}) extends A<String>;
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,31 @@
// 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 two formal parameters with the same name.
/// Test declaring vs. declaring parameters.
/// @description Check that it is a compile-time error if a primary constructor
/// contains two formal parameters with the same name. Test declaring vs.
/// declaring parameters.
/// @author sgrekhov22@gmail.com

// SharedOptions=--enable-experiment=primary-constructors
Expand All @@ -32,24 +36,20 @@ class C1<T>(var T v, var T v);
// [analyzer] unspecified
// [cfe] unspecified

class C2 {
this(final String v, [final String v = ""]);
// ^
class C2(final String v, [final String v = ""]);
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

class C3<T>(final T? v, {final T? v});
// ^
// [analyzer] unspecified
// [cfe] unspecified

class C4 {
this(var String v, {required var String v});
// ^
class C4(var String v, {required var String v});
// ^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E1<T>(final T v, final T v) {
// ^
Expand All @@ -58,12 +58,11 @@ enum E1<T>(final T v, final T v) {
e0<int>(1, 2);
}

enum E2 {
e0("1", "2");
this(final String v, [final String v = ""]);
// ^
enum E2(final String v, [final String v = ""]) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
e0("1", "2");
}

enum E3<T>(final T? v, {final T? v}) {
Expand All @@ -73,12 +72,11 @@ enum E3<T>(final T? v, {final T? v}) {
e0<int>(1);
}

enum E4 {
e0("1", v: "2");
this(final String v, {required final String v});
// ^
enum E4(final String v, {required final String v}) {
// ^
// [analyzer] unspecified
// [cfe] unspecified
e0("1", v: "2");
}

main() {
Expand Down
Loading