-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes #2436. Add tests for external and redirecting constructors with…
… initializing formals (#2460)
- Loading branch information
Showing
8 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A01_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
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); | ||
} |
36 changes: 36 additions & 0 deletions
36
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A01_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
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); | ||
} |
36 changes: 36 additions & 0 deletions
36
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A01_t03.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
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); | ||
} |
36 changes: 36 additions & 0 deletions
36
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A01_t04.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
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); | ||
} |
35 changes: 35 additions & 0 deletions
35
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t01.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
/// @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); | ||
} |
35 changes: 35 additions & 0 deletions
35
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t02.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
/// @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); | ||
} |
35 changes: 35 additions & 0 deletions
35
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t03.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
/// @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); | ||
} |
35 changes: 35 additions & 0 deletions
35
...e/Classes/Constructors/Generative_Constructors/initializing_formal_parameter_A02_t04.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 [email protected] | ||
/// @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); | ||
} |