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

#2559. Add extension types to augmented expression tests. Part 3. #2961

Merged
merged 3 commits into from
Nov 1, 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
Expand Up @@ -65,6 +65,12 @@ extension Ext on A {
static String get augmented => "Ext.augmented, shouldn't be invoked";
}

extension type ET(int _) {
static var staticVariable = foo;
static final finalStaticVariable = foo;
static String get augmented => "ET.augmented, shouldn't be invoked";
}

class MA = Object with M;

main() {
Expand All @@ -83,4 +89,6 @@ main() {
Expect.equals("1: Original 25, 2: Original 26", E.e1.finalInstanceVariable());
Expect.equals("1: Original 27, 2: Original 28", Ext.staticVariable);
Expect.equals("1: Original 29, 2: Original 30", Ext.finalStaticVariable);
Expect.equals("1: Original 31, 2: Original 32", Ext.staticVariable);
Expect.equals("1: Original 33, 2: Original 34", Ext.finalStaticVariable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ augment extension Ext {
augment static var staticVariable = "1: $augmented, 2: " + augmented;
augment static final finalStaticVariable = "1: $augmented, 2: " + augmented;
}

augment extension type ET {
augment static var staticVariable = "1: $augmented, 2: " + augmented;
augment static final finalStaticVariable = "1: $augmented, 2: " + augmented;
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ extension Ext on A {
static String augmented() => "Ext.augmented(), shouldn't be invoked";
}

extension type ET(int _) {
static var staticVariable = foo;
static final finalStaticVariable = foo;
static String augmented() => "Ext.augmented(), shouldn't be invoked";
}

class MA = Object with M;

main() {
Expand All @@ -81,4 +87,6 @@ main() {
Expect.equals("Augment: Original", E.e1.finalInstanceVariable());
Expect.equals("Augment: Original", Ext.staticVariable);
Expect.equals("Augment: Original", Ext.finalStaticVariable);
Expect.equals("Augment: Original", ET.staticVariable);
Expect.equals("Augment: Original", ET.finalStaticVariable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,12 @@ augment extension Ext {
return "Augment: " + augmented();
};
}

augment extension type ET {
augment static var staticVariable = () {
return "Augment: " + augmented();
};
augment static final finalStaticVariable = () {
return "Augment: " + augmented();
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,18 @@ extension Ext on A {
static String augmented() => "Ext.augmented(), shouldn't be invoked";
}

extension type ET(int _) {
static String staticVariable = "Original";
static final String finalStaticVariable = "Original";
static String augmented() => "Ext.augmented(), shouldn't be invoked";
}

main() {
print(topLevelVariable);
print(finalTopLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ augment extension Ext {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static String staticVariable = "Augment: ${augmented()}";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment static final String finalStaticVariable = "Augment: ${augmented()}";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,18 @@ extension Ext on A {
static void set augmented(String _) {}
}

extension type ET(int _) {
static String staticVariable = "Original";
static final String finalStaticVariable = "Original";
static void set augmented(String _) {}
}

main() {
print(topLevelVariable);
print(finalTopLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,15 @@ augment extension Ext {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static String staticVariable = "Augment: ${augmented = 'n'}";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
augment static final String finalStaticVariable =
"Augment: ${augmented = 'o'}";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ extension Ext on A {
static bool augmented = false;
}

extension type ET(int _) {
static String staticVariable = "Original";
static final String finalStaticVariable = "Original";
static bool augmented = false;
}

class MA = Object with M;

main() {
Expand All @@ -80,4 +86,6 @@ main() {
Expect.equals("Original - augment", E.e1.finalInstanceVariable);
Expect.equals("Original - augment", Ext.staticVariable);
Expect.equals("Original - augment", Ext.finalStaticVariable);
Expect.equals("Original - augment", ET.staticVariable);
Expect.equals("Original - augment", ET.finalStaticVariable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ augment extension Ext {
augment static String staticVariable = augmented + " - augment";
augment static final String finalStaticVariable = augmented + " - augment";
}

augment extension type ET {
augment static String staticVariable = augmented + " - augment";
augment static final String finalStaticVariable = augmented + " - augment";
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ extension Ext on A {
static final String augmented = "Ext.augmented, shouldn't be used";
}

extension type ET(int _) {
static String staticVariable = "Original";
static final String finalStaticVariable = "Original";
static final String augmented = "ET.augmented, shouldn't be used";
}

class MA = Object with M;

main() {
Expand All @@ -81,4 +87,6 @@ main() {
Expect.equals("Augment2: Augment1: Original", E.e1.finalInstanceVariable);
Expect.equals("Augment2: Augment1: Original", Ext.staticVariable);
Expect.equals("Augment2: Augment1: Original", Ext.finalStaticVariable);
Expect.equals("Augment2: Augment1: Original", ET.staticVariable);
Expect.equals("Augment2: Augment1: Original", ET.finalStaticVariable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ augment extension Ext {
augment static String staticVariable = "Augment1: $augmented";
augment static final String finalStaticVariable = "Augment1: $augmented";
}

augment extension type ET {
augment static String staticVariable = "Augment1: $augmented";
augment static final String finalStaticVariable = "Augment1: $augmented";
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ augment extension Ext {
augment static String staticVariable = "Augment2: $augmented";
augment static final String finalStaticVariable = "Augment2: $augmented";
}

augment extension type ET {
augment static String staticVariable = "Augment2: $augmented";
augment static final String finalStaticVariable = "Augment2: $augmented";
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ extension Ext on A {
static final augmented = "Ext.augmented, should not be used";
}

extension type ET(int _) {
static String? staticVariable;
static final augmented = "ET.augmented, should not be used";
}

main() {
topLevelVariable;
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ augment extension Ext {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static String? staticVariable = "Augment: $augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ extension Ext on A {
static final augmented = "Ext.augmented, should not be used";
}

extension type ET(int _) {
static Function? staticVariable;
static final augmented = "Ext.augmented, should not be used";
}

main() {
topLevelVariable;
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,12 @@ augment extension Ext {
// [cfe] unspecified
};
}

augment extension type ET {
augment static Function? staticVariable = () {
return "Augment: $augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ extension Ext on A {
static final augmented = "Ext.augmented, should not be used";
}

extension type ET(int _) {
static late String? staticVariable;
static final augmented = "ET.augmented, should not be used";
}

main() {
topLevelVariable;
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,10 @@ augment extension Ext {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
augment static late String? staticVariable = "Augment: $augmented";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ augment class C {
}

augment enum E {
augment e1("x");
augment e1;

augment final String finalInstanceVariable = "Augment: $augmented";
// ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ augment class C {
}

augment enum E {
augment e1(foo);
augment e1;
augment final Function finalInstanceVariable = () {
return "Augment: $augmented";
// ^^^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ extension Ext on A {
static String get augmented => "Ext.augmented, shouldn't be invoked";
}

extension type ET(int _) {
static late var staticVariable = foo;
static late final finalStaticVariable = foo;
static String get augmented => "ET.augmented, shouldn't be invoked";
}

class MA = Object with M;

main() {
Expand All @@ -79,4 +85,6 @@ main() {
Expect.equals("1: Original 23, 2: Original 24", E.finalStaticVariable);
Expect.equals("1: Original 25, 2: Original 26", Ext.staticVariable);
Expect.equals("1: Original 27, 2: Original 28", Ext.finalStaticVariable);
Expect.equals("1: Original 29, 2: Original 30", ET.staticVariable);
Expect.equals("1: Original 31, 2: Original 32", ET.finalStaticVariable);
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ augment extension Ext {
augment static late final finalStaticVariable =
"1: $augmented, 2: " + augmented;
}

augment extension type ET {
augment static late var staticVariable = "1: $augmented, 2: " + augmented;
augment static late final finalStaticVariable =
"1: $augmented, 2: " + augmented;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ extension Ext on A {
static Function? staticVariable = () {};
}

extension type ET(int _) {
static Function? staticVariable = () {};
}

main() {
print(topLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,13 @@ augment extension Ext {
return "Augmented";
};
}

augment extension type ET {
augment static Function? staticVariable = () {
var augmented = 42;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
return "Augmented";
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ extension Ext on A {
static Function? staticVariable = () {};
}

extension type ET(int _) {
static Function? staticVariable = () {};
}

main() {
print(topLevelVariable);
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,12 @@ augment extension Ext {
// [cfe] unspecified
};
}

augment extension type ET {
augment static Function? staticVariable = () {
int augmented() => 42;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
};
}
Loading