Skip to content

Commit 5198824

Browse files
authored
#3054. Add more test cases to closurization tests. Part 2. (#3069)
Add more test cases to closurization tests. Part 2.
1 parent b14b080 commit 5198824

14 files changed

+1079
-67
lines changed

Language/Expressions/Property_Extraction/Instance_Method_Closurization/method_closurization_named_params_A03_t01.dart

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,46 @@ class C {
4040
}
4141
}
4242

43+
mixin M {
44+
num m<Y extends num>(
45+
covariant int r1,
46+
covariant Y r2, {
47+
covariant int p1 = 0
48+
}) {
49+
return 42;
50+
}
51+
}
52+
class MO = Object with M;
53+
54+
enum E {
55+
e0;
56+
num m<Y extends num>(
57+
covariant int r1,
58+
covariant Y r2, {
59+
covariant int p1 = 0
60+
}) {
61+
return 42;
62+
}
63+
}
64+
4365
main() {
44-
C o = C();
45-
final f = o.m;
46-
f.expectStaticType<
47-
Exactly<num Function<Y extends num>(int r1, Y r2, {int p1})>
48-
>();
66+
C c = C();
67+
final fc = c.m;
68+
fc.expectStaticType<
69+
Exactly<num Function<Y extends num>(int r1, Y r2, {int p1})>>();
70+
Expect.isTrue(
71+
fc is num Function<Y extends num>(Object? r1, Object? r2, {Object? p1}));
72+
73+
M m = MO();
74+
final fm = m.m;
75+
fm.expectStaticType<
76+
Exactly<num Function<Y extends num>(int r1, Y r2, {int p1})>>();
77+
Expect.isTrue(
78+
fm is num Function<Y extends num>(Object? r1, Object? r2, {Object? p1}));
4979

80+
final fe = E.e0.m;
81+
fe.expectStaticType<
82+
Exactly<num Function<Y extends num>(int r1, Y r2, {int p1})>>();
5083
Expect.isTrue(
51-
f is num Function<Y extends num>(Object? r1, Object? r2, {Object? p1})
52-
);
84+
fe is num Function<Y extends num>(Object? r1, Object? r2, {Object? p1}));
5385
}

Language/Expressions/Property_Extraction/Instance_Method_Closurization/method_closurization_named_params_A03_t02.dart

Lines changed: 117 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,130 @@ class C<X> {
3636
}
3737
}
3838

39+
mixin M<X> {
40+
X m<Y extends X>(X r1, Y r2, {required X p1}) {
41+
return 42 as X;
42+
}
43+
}
44+
class MO<X> = Object with M<X>;
45+
46+
enum E<X> {
47+
e0;
48+
X m<Y extends X>(X r1, Y r2, {required X p1}) {
49+
return 42 as X;
50+
}
51+
}
52+
53+
class A<X> {}
54+
extension Ext<X> on A<X> {
55+
X m<Y extends X>(X r1, Y r2, {required X p1}) {
56+
return 42 as X;
57+
}
58+
}
59+
60+
extension type ET<X>(int _) {
61+
X m<Y extends X>(X r1, Y r2, {required X p1}) {
62+
return 42 as X;
63+
}
64+
}
65+
3966
main() {
40-
C<Object?> o = C<Object?>();
41-
final f = o.m;
42-
f.expectStaticType<
43-
Exactly<Object? Function<Y extends Object?>(Object? r1, Y r2, {required Object? p1})>
67+
C<Object?> c = C<Object?>();
68+
final fc = c.m;
69+
fc.expectStaticType<
70+
Exactly<
71+
Object? Function<Y extends Object?>(
72+
Object? r1,
73+
Y r2, {
74+
required Object? p1,
75+
})
76+
>
4477
>();
4578

4679
Expect.isTrue(
47-
f is Object? Function<Y extends Object?>( // ignore: unnecessary_type_check
80+
fc is Object? Function<Y extends Object?>( // ignore: unnecessary_type_check
4881
Object? r1,
4982
Y r2, {
5083
required Object? p1,
5184
}),
5285
);
86+
87+
M<Object?> m = MO<Object?>();
88+
final fm = m.m;
89+
fm.expectStaticType<
90+
Exactly<
91+
Object? Function<Y extends Object?>(
92+
Object? r1,
93+
Y r2, {
94+
required Object? p1,
95+
})
96+
>
97+
>();
98+
99+
Expect.isTrue(
100+
fm is Object? Function<Y extends Object?>( // ignore: unnecessary_type_check
101+
Object? r1,
102+
Y r2, {
103+
required Object? p1,
104+
}),
105+
);
106+
107+
final fe = E.e0.m;
108+
fe.expectStaticType<
109+
Exactly<
110+
Object? Function<Y extends Object?>(
111+
Object? r1,
112+
Y r2, {
113+
required Object? p1,
114+
})
115+
>
116+
>();
117+
118+
Expect.isTrue(
119+
fe is Object? Function<Y extends Object?>( // ignore: unnecessary_type_check
120+
Object? r1,
121+
Y r2, {
122+
required Object? p1,
123+
}),
124+
);
125+
126+
A<Object?> a = A<Object?>();
127+
final fa = a.m;
128+
fa.expectStaticType<
129+
Exactly<
130+
Object? Function<Y extends Object?>(
131+
Object? r1,
132+
Y r2, {
133+
required Object? p1,
134+
})
135+
>
136+
>();
137+
138+
Expect.isTrue(
139+
fa is Object? Function<Y extends Object?>( // ignore: unnecessary_type_check
140+
Object? r1,
141+
Y r2, {
142+
required Object? p1,
143+
}),
144+
);
145+
146+
ET<Object?> et = ET<Object?>(0);
147+
final fet = et.m;
148+
fet.expectStaticType<
149+
Exactly<
150+
Object? Function<Y extends Object?>(
151+
Object? r1,
152+
Y r2, {
153+
required Object? p1,
154+
})
155+
>
156+
>();
157+
158+
Expect.isTrue(
159+
fet is Object? Function<Y extends Object?>( // ignore: unnecessary_type_check
160+
Object? r1,
161+
Y r2, {
162+
required Object? p1,
163+
}),
164+
);
53165
}

Language/Expressions/Property_Extraction/Instance_Method_Closurization/method_closurization_named_params_A03_t03.dart

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,59 @@ class C<X extends num> {
4040
}
4141
}
4242

43+
mixin M<X extends num> {
44+
X m<Y extends X>(
45+
covariant X r1,
46+
covariant Y r2, {
47+
required covariant int p1,
48+
}) {
49+
return 42 as X;
50+
}
51+
}
52+
class MO<X extends num> = Object with M<X>;
53+
54+
enum E<X extends num> {
55+
e0;
56+
X m<Y extends X>(
57+
covariant X r1,
58+
covariant Y r2, {
59+
required covariant int p1,
60+
}) {
61+
return 42 as X;
62+
}
63+
}
64+
4365
main() {
44-
var o = C<num>();
45-
final f = o.m;
46-
f.expectStaticType<
66+
var c = C<num>();
67+
final fc = c.m;
68+
fc.expectStaticType<
4769
Exactly<num Function<Y extends num>(num r1, Y r2, {required int p1})>
4870
>();
4971

5072
Expect.isTrue(
51-
f is num Function<Y extends num>(
52-
Object? r1,
53-
Object? r2, {
54-
required Object? p1,
73+
fc is num Function<Y extends num>(Object? r1, Y r2, {required Object? p1,}),
74+
);
75+
76+
M<num> m = MO<num>();
77+
final fm = m.m;
78+
fm.expectStaticType<
79+
Exactly<num Function<Y extends num>(num r1, Y r2, {required int p1})>
80+
>();
81+
82+
Expect.isTrue(
83+
fm is num Function<Y extends num>(
84+
Object? r1,
85+
Object? r2, {
86+
required Object? p1,
5587
}),
5688
);
89+
90+
final fe = E.e0.m;
91+
fe.expectStaticType<
92+
Exactly<num Function<Y extends num>(num r1, Y r2, {required int p1})>
93+
>();
94+
95+
Expect.isTrue(
96+
fe is num Function<Y extends num>(Object? r1, Y r2, {required Object? p1}),
97+
);
5798
}

0 commit comments

Comments
 (0)