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 and enums to augmenting constructors tests #2971

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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 @@ -32,11 +32,16 @@ extension Ext on A {
A test() => this;
}

extension type ET(int _) {
ET test() => this;
}

class MA = Object with M;

main() {
C().test();
MA().test();
E.e0.test();
A().test();
ET(0).test();
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,10 @@ augment extension Ext {
return this;
}
}

augment extension type ET {
augment ET test() {
Expect.identical(this, augmented());
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ main() {
Expect.equals("augmented", E.e1.instanceMethod());
Expect.equals("augmented", Ext.staticMethod());
Expect.equals("augmented", A().instanceMethod());
Expect.equals("augmented", ET.staticMethod());
Expect.equals("augmented", ET(0).instanceMethod());
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ extension Ext on A {
static String staticMethod() => augmented();
String instanceMethod() => augmented();
}

extension type ET(int _) {
static String staticMethod() => augmented();
String instanceMethod() => augmented();
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ main() {
Expect.equals("augmented", E.e1.instanceMethod());
Expect.equals("augmented", Ext.staticMethod());
Expect.equals("augmented", A().instanceMethod());
Expect.equals("augmented", ET.staticMethod());
Expect.equals("augmented", ET(0).instanceMethod());
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ extension Ext on A {
static String staticMethod() => augmented;
String instanceMethod() => augmented;
}

extension type ET(int _) {
static String staticMethod() => augmented;
String instanceMethod() => augmented;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,6 @@ main() {
Expect.equals("augmented", E.e1.instanceMethod());
Expect.equals("augmented", Ext.staticMethod());
Expect.equals("augmented", A().instanceMethod());
Expect.equals("augmented", ET.staticMethod());
Expect.equals("augmented", ET(0).instanceMethod());
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,8 @@ extension Ext on A {
static String staticMethod() => augmented;
String instanceMethod() => augmented;
}

extension type ET(int _) {
static String staticMethod() => augmented;
String instanceMethod() => augmented;
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ main() {
Expect.equals("augmented = Ext.staticMethod", _log);
A().instanceMethod();
Expect.equals("augmented = Ext.instanceMethod", _log);
ET.staticMethod();
Expect.equals("augmented = ET.staticMethod", _log);
ET(0).instanceMethod();
Expect.equals("augmented = ET.instanceMethod", _log);
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ extension Ext on A {
augmented = "Ext.instanceMethod";
}
}

extension type ET(int _) {
static void staticMethod() {
augmented = "ET.staticMethod";
}
void instanceMethod() {
augmented = "ET.instanceMethod";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum E {e0;}

class A {}
extension Ext on A {}
extension type ET(int _) {}

main() {
print(C1);
Expand All @@ -31,4 +32,5 @@ main() {
print(M2);
print(E);
print(A);
print(ET);
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,10 @@ augment extension Ext {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET {
static String augmented = "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ enum E2 {e0;}
class A {}
extension Ext1 on A {}
extension Ext2 on A {}
extension type ET1(int _) {}
extension type ET2(int _) {}

main() {
print(C1);
Expand All @@ -34,4 +36,6 @@ main() {
print(E1);
print(E2);
print(A);
print(ET1);
print(ET2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ augment extension Ext2 {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET1 {
static String get augmented => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET2 {
String get augmented => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ enum E2 {e0;}
class A {}
extension Ext1 on A {}
extension Ext2 on A {}
extension type ET1(int _) {}
extension type ET2(int _) {}

main() {
print(C1);
Expand All @@ -34,4 +36,6 @@ main() {
print(E1);
print(E2);
print(A);
print(ET1);
print(ET2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ augment extension Ext2 {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET1 {
static String augmented() => "static";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET2 {
String augmented() => "instance";
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ enum E2 {e0;}
class A {}
extension Ext1 on A {}
extension Ext2 on A {}
extension type ET1(int _) {}
extension type ET2(int _) {}

main() {
print(C1);
Expand All @@ -34,4 +36,6 @@ main() {
print(E1);
print(E2);
print(A);
print(ET1);
print(ET2);
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,17 @@ augment extension Ext2 {
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET1 {
static void set augmented(String _) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}

augment extension type ET2 {
void set augmented(String _) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ enum E {e0;}

class A {}
extension Ext on A {}
extension type ET(int _) {}

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

augment extension type ET {
static void staticMethod<augmented>(int v) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

void instanceMethod<augmented>(int v) {}
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ enum E {e0;}

class A {}
extension Ext on A {}
extension type ET(int _) {}

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

augment extension type ET {
static augmented? staticVariable = null;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

static augmented? get staticGetter => null;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

static augmented? staticMethod() => null;
// ^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augmented? get instanceGetter => null;
//^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified

augmented? instanceMethod() => null;
//^^^^^^^^^
// [analyzer] unspecified
// [cfe] unspecified
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ enum E {e0;}

class A {}
extension Ext on A {}
extension type ET(int _) {}

main() {
print(C);
print(M);
print(E);
print(A);
print(ET);
}
Loading