Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2436. Add tests for external and redirecting constructors with initializing formals #2460

Merged
merged 1 commit into from
Jan 2, 2024
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
@@ -0,0 +1,36 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in a redirecting constructor.
/// @author sgrekhov22@gmail.com

class C {
int? x;

C(this.x);
C.n(this.x) : this(0);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(1);

final int x;
const E(this.x);
const E.n(this.x) : this(1);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in a redirecting constructor.
/// @author sgrekhov22@gmail.com

class C {
int x;

C({this.x = 0});
C.n({this.x = 1}) : this(x: 0);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(x: 1);

final int x;
const E({this.x = 0});
const E.n({this.x = 2}) : this(x: 1);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in a redirecting constructor.
/// @author sgrekhov22@gmail.com

class C {
int x;

C({required this.x});
C.n({required this.x}) : this(x: 0);
// ^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(x: 1);

final int x;
const E({required this.x});
const E.n({required this.x}) : this(x: 1);
// ^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in a redirecting constructor.
/// @author sgrekhov22@gmail.com

class C {
int x;

C([this.x = 0]);
C.n([this.x = 1]) : this(0);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(1);

final int x;
const E([this.x = 0]);
const E.n([this.x = 2]) : this(1);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in an external constructor.
/// @author sgrekhov22@gmail.com
/// @issue 54485

class C {
int? x;

external C(this.x);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(1);

final int x;
external const E(this.x);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in an external constructor.
/// @author sgrekhov22@gmail.com
/// @issue 54485

class C {
int x;

external C({this.x = 0});
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(x: 1);

final int x;
external const E({this.x = 0});
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in an external constructor.
/// @author sgrekhov22@gmail.com
/// @issue 54485

class C {
int x;

external C({required this.x});
// ^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(x: 1);

final int x;
external const E({required this.x});
// ^^^^^^^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// @assertion It is a compile-time error for an initializing formal parameter
/// to occur in a redirecting or external constructor.
///
/// @description Checks that it is a compile-time error when the initializing
/// formal parameter occurs in an external constructor.
/// @author sgrekhov22@gmail.com
/// @issue 54485

class C {
int x;

external C([this.x = 0]);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

enum E {
a(1);

final int x;
external const E([this.x = 0]);
// ^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

main() {
print(C);
print(E);
}