-
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.
#2559. Add extension types and enums to augmenting constructors test.…
… Part 2. (#2972) Add extension types and enums to augmenting constructors test. Part 2.
- Loading branch information
Showing
35 changed files
with
460 additions
and
112 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
/// etc). | ||
/// | ||
/// @description Checks that it is a compile-time error if the resulting | ||
/// constructor has a redirecting initializer and other initializers. | ||
/// constructor has a redirecting initializer and initializer list elements. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
@@ -19,7 +19,7 @@ part 'augmenting_constructors_A06_t01_lib.dart'; | |
class C { | ||
int x; | ||
C(this.x); | ||
C.foo(): this(0); | ||
C.foo() : this(0); | ||
//^^^^^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
|
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 |
---|---|---|
|
@@ -9,13 +9,13 @@ | |
/// etc). | ||
/// | ||
/// @description Checks that it is a compile-time error if the resulting | ||
/// constructor has a redirecting initializer and other initializers. | ||
/// constructor has a redirecting initializer and initializer list elements. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
part of 'augmenting_constructors_A06_t01.dart'; | ||
|
||
augment class C { | ||
augment C.foo(): x = 1; | ||
augment C.foo() : x = 1; | ||
} |
33 changes: 33 additions & 0 deletions
33
LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_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,33 @@ | ||
// 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 if: | ||
/// ... | ||
/// - The resulting constructor is not valid (it has a redirection as well as | ||
/// some initializer list elements, or it has multiple super initializers, | ||
/// etc). | ||
/// | ||
/// @description Checks that it is a compile-time error if the resulting | ||
/// constructor has multiple super initializers. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
part 'augmenting_constructors_A06_t02_lib.dart'; | ||
|
||
class A { | ||
int x; | ||
A(this.x); | ||
} | ||
|
||
class C extends A { | ||
C() : super(0); | ||
//^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
main() { | ||
print(C); | ||
} |
21 changes: 21 additions & 0 deletions
21
LanguageFeatures/Augmentation-libraries/augmenting_constructors_A06_t02_lib.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,21 @@ | ||
// 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 if: | ||
/// ... | ||
/// - The resulting constructor is not valid (it has a redirection as well as | ||
/// some initializer list elements, or it has multiple super initializers, | ||
/// etc). | ||
/// | ||
/// @description Checks that it is a compile-time error if the resulting | ||
/// constructor has multiple super initializers. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
part of 'augmenting_constructors_A06_t02.dart'; | ||
|
||
augment class C { | ||
augment C() : super(1); | ||
} |
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -8,14 +8,12 @@ | |
/// - The augmented constructor has an initializer list or a body, or it has a | ||
/// redirection. | ||
/// | ||
/// @description Checks that it is not an error to declare an augmenting | ||
/// redirecting generative constructor more than once and the fully merged | ||
/// constructor has no errors. | ||
/// @description Checks that it is a compile-time error to declare an augmenting | ||
/// redirecting generative constructor more than once. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
import '../../Utils/expect.dart'; | ||
part 'augmenting_constructors_A18_t04_lib.dart'; | ||
|
||
class C { | ||
|
@@ -24,6 +22,19 @@ class C { | |
C.foo(int x); | ||
} | ||
|
||
enum E { | ||
e0(0), e1.foo(1); | ||
final int x; | ||
const E(this.x); | ||
const E.foo(int x); | ||
} | ||
|
||
extension type ET(int x) { | ||
ET.foo(int x); | ||
} | ||
|
||
main() { | ||
Expect.equals(2, C.foo(1)); | ||
print(C); | ||
print(E); | ||
print(ET); | ||
} |
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 |
---|---|---|
|
@@ -9,15 +9,34 @@ | |
/// redirection. | ||
/// | ||
/// @description Checks that it is a compile-time error to declare an augmenting | ||
/// redirecting generative constructor if the augmented constructor has a | ||
/// non-empty initializing list. | ||
/// redirecting generative constructor more than once. | ||
/// @author [email protected] | ||
// SharedOptions=--enable-experiment=macros | ||
|
||
part of 'augmenting_constructors_A18_t04.dart'; | ||
|
||
augment class C { | ||
augment C.foo(int x): this.foo(x); // Cyclic! But it is fixed below | ||
augment C.foo(int x): this(x + 1); // Not a cyclic now | ||
augment C.foo(int x) : this(x + 1); // Ok | ||
augment C.foo(int x) : this(x + 2); // Augmented constructor already has a redirection | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment enum E { | ||
augment e0; | ||
augment const E.foo(int x) : this(x + 1); | ||
augment const E.foo(int x) : this(x + 2); | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} | ||
|
||
augment extension type ET { | ||
augment ET.foo(int x) : this(x + 1); | ||
augment ET.foo(int x) : this(x + 2); | ||
// ^ | ||
// [analyzer] unspecified | ||
// [cfe] unspecified | ||
} |
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 |
---|---|---|
|
@@ -21,6 +21,11 @@ class C { | |
C.foo() {} | ||
} | ||
|
||
extension type ET(int x) { | ||
ET.foo(int x) {} | ||
} | ||
|
||
main() { | ||
print(C); | ||
print(ET); | ||
} |
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
Oops, something went wrong.