Skip to content

Commit fe7a1a9

Browse files
authored
Fixes #2435. Fix roll failures (#2437)
Fix roll failures
1 parent 0c3a96a commit fe7a1a9

File tree

8 files changed

+132
-36
lines changed

8 files changed

+132
-36
lines changed

Language/Classes/Constructors/Factories/redirecting_constructor_t06.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@
1717
/// @author [email protected]
1818
1919
class F {
20-
external factory F(num x) = C;
21-
// ^
20+
external factory F() = C;
21+
// ^
2222
// [analyzer] unspecified
2323
// [cfe] unspecified
2424

25-
external factory F.f1(num x) = C.f1;
26-
// ^
25+
external factory F.f1() = C.f1;
26+
// ^
2727
// [analyzer] unspecified
2828
// [cfe] unspecified
2929
}
3030

3131
class C implements F {
32-
num x;
33-
34-
external C(this.x);
35-
C.f1(this.x);
32+
external C();
33+
C.f1();
3634
}
3735

3836
enum E {

Language/Classes/Constructors/Factories/return_type_A03_t02.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
/// null object.
1010
/// @author [email protected]
1111
12+
// Requirements=nnbd-strong
13+
1214
import "../../../../Utils/expect.dart";
1315

1416
class C {

LanguageFeatures/Extension-types/exhaustiveness_enum_A01_t04.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ String testExpression1(ET1 e) =>
4747
E.c => "c"
4848
};
4949

50-
String testExpression2(ET2<num> e) =>
50+
String testExpression2(ET2 e) =>
5151
switch (e) {
5252
E.a => "a",
5353
E.b => "b",

LanguageFeatures/Extension-types/exhaustiveness_enum_A02_t01.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ extension type ET1<T>(E<T> _) {}
2222
extension type ET2<T>(E<T> _) implements E<T> {}
2323

2424
String testStatement1<T extends num>(ET1<T> e) {
25+
// ^^^^^^^^^^^^^^
26+
// [analyzer] unspecified
2527
switch (e) {
2628
//^^^^^^
27-
// [analyzer] unspecified
2829
// [cfe] unspecified
2930
case E.a:
3031
return "a";
@@ -34,9 +35,10 @@ String testStatement1<T extends num>(ET1<T> e) {
3435
}
3536

3637
String testStatement2<T extends num>(ET2<T> e) {
38+
// ^^^^^^^^^^^^^^
39+
// [analyzer] unspecified
3740
switch (e) {
3841
//^^^^^^
39-
// [analyzer] unspecified
4042
// [cfe] unspecified
4143
case E.a:
4244
return "a";
@@ -64,19 +66,21 @@ String testExpression2<T extends num>(ET2<T> e) =>
6466
};
6567

6668
String testStatement3(ET1<num> e) {
69+
// ^^^^^^^^^^^^^^
70+
// [analyzer] unspecified
6771
switch (e) {
6872
//^^^^^^
69-
// [analyzer] unspecified
7073
// [cfe] unspecified
7174
case E.a:
7275
return "ok";
7376
}
7477
}
7578

7679
String testStatement4(ET2<num> e) {
80+
// ^^^^^^^^^^^^^^
81+
// [analyzer] unspecified
7782
switch (e) {
7883
//^^^^^^
79-
// [analyzer] unspecified
8084
// [cfe] unspecified
8185
case E.a:
8286
return "ok";

LanguageFeatures/Extension-types/exhaustiveness_enum_A02_t02.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ extension type ET1(E _) {}
2020
extension type ET2(E _) implements E {}
2121

2222
String testStatement1(ET1 e) {
23+
// ^^^^^^^^^^^^^^
24+
// [analyzer] unspecified
2325
switch (e) {
2426
//^^^^^^
25-
// [analyzer] unspecified
2627
// [cfe] unspecified
2728
case E.a:
2829
return "a";
@@ -32,9 +33,10 @@ String testStatement1(ET1 e) {
3233
}
3334

3435
String testStatement2(ET2 e) {
36+
// ^^^^^^^^^^^^^^
37+
// [analyzer] unspecified
3538
switch (e) {
3639
//^^^^^^
37-
// [analyzer] unspecified
3840
// [cfe] unspecified
3941
case E.a:
4042
return "a";

LanguageFeatures/Extension-types/exhaustiveness_map_A02_t01.dart

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,6 @@ String test1_2(ET2<bool, bool> m) =>
3535
Map() => "other"
3636
};
3737

38-
String test2_1(ET1<bool, bool> m) {
39-
switch (m) {
40-
case {true: true}:
41-
return "case-1";
42-
case {true: false}:
43-
return "case-2";
44-
case {false: true}:
45-
return "case-3";
46-
case {false: false}:
47-
return "case-4";
48-
case Map():
49-
return "other";
50-
}
51-
}
52-
5338
String test2_2(ET2<bool, bool> m) {
5439
switch (m) {
5540
case {true: true}:
@@ -68,14 +53,11 @@ String test2_2(ET2<bool, bool> m) {
6853
main() {
6954
Expect.equals("case-1", test1_1(ET1({true: true})));
7055
Expect.equals("case-2", test1_2(ET2({true: false})));
71-
Expect.equals("case-3", test2_1(ET1({false: true})));
7256
Expect.equals("case-4", test2_2(ET2({false: false})));
7357
Expect.equals("other", test1_1(ET1<bool, bool>({})));
7458
Expect.equals("other", test1_2(ET2<bool, bool>({})));
75-
Expect.equals("other", test2_1(ET1<bool, bool>({})));
7659
Expect.equals("other", test2_2(ET2<bool, bool>({})));
77-
Expect.equals("other", test1_1(ET1({true: true, false: false})));
78-
Expect.equals("other", test1_2(ET2({true: false, false: false})));
79-
Expect.equals("other", test2_1(ET1({false: true, true: true})));
80-
Expect.equals("other", test2_2(ET2({false: false, true: true})));
60+
Expect.equals("case-1", test1_1(ET1({true: true, false: false})));
61+
Expect.equals("case-2", test1_2(ET2({true: false, false: false})));
62+
Expect.equals("case-1", test2_2(ET2({false: false, true: true})));
8163
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Exhaustiveness with map patterns can only be achieved when there
6+
/// is an exhaustive pattern in addition to any map patterns
7+
///
8+
/// @description Check that a switch statement with a value type an extension
9+
/// type with a `Map` as a representation type but which doesn't implement `Map`
10+
/// is not exhaustive
11+
/// @author [email protected]
12+
13+
// SharedOptions=--enable-experiment=inline-class
14+
15+
extension type ET1<K, V>(Map<K, V> _) {}
16+
17+
String test(ET1<bool, bool> m) {
18+
// ^^^^
19+
// [analyzer] unspecified
20+
// [cfe] unspecified
21+
switch (m) {
22+
case {true: true}:
23+
return "case-1";
24+
case {true: false}:
25+
return "case-2";
26+
case {false: true}:
27+
return "case-3";
28+
case {false: false}:
29+
return "case-4";
30+
case Map():
31+
return "other";
32+
}
33+
}
34+
35+
main() {
36+
test(ET1({false: true}));
37+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
/// @assertion Exhaustiveness with map patterns can only be achieved when there
6+
/// is an exhaustive pattern in addition to any map patterns
7+
///
8+
/// @description Check that a switch statement/expression with map patterns and
9+
/// additional exhaustive pattern can be exhaustive.
10+
/// @author [email protected]
11+
12+
import "../../../Utils/expect.dart";
13+
14+
String test1_1(Map<bool, bool> m) =>
15+
switch (m) {
16+
{true: true} => "case-1",
17+
{true: false} => "case-2",
18+
{false: true} => "case-3",
19+
{false: false} => "case-4",
20+
Map() => "other"
21+
};
22+
23+
String test1_2(Map<bool, bool> m) =>
24+
switch (m) {
25+
{true: true} => "case-1",
26+
{true: false} => "case-2",
27+
{false: true} => "case-3",
28+
{false: false} => "case-4",
29+
Map() => "other"
30+
};
31+
32+
String test2_1(Map<bool, bool> m) {
33+
switch (m) {
34+
case {true: true}:
35+
return "case-1";
36+
case {true: false}:
37+
return "case-2";
38+
case {false: true}:
39+
return "case-3";
40+
case {false: false}:
41+
return "case-4";
42+
case Map():
43+
return "other";
44+
}
45+
}
46+
47+
String test2_2(Map<bool, bool> m) {
48+
switch (m) {
49+
case {true: true}:
50+
return "case-1";
51+
case {true: false}:
52+
return "case-2";
53+
case {false: true}:
54+
return "case-3";
55+
case {false: false}:
56+
return "case-4";
57+
case Map():
58+
return "other";
59+
}
60+
}
61+
62+
main() {
63+
Expect.equals("other", test1_1(<bool, bool>{}));
64+
Expect.equals("other", test1_2(<bool, bool>{}));
65+
Expect.equals("other", test2_1(<bool, bool>{}));
66+
Expect.equals("other", test2_2(<bool, bool>{}));
67+
Expect.equals("case-1", test1_1({true: true, false: false}));
68+
Expect.equals("case-2", test1_2({true: false, false: false}));
69+
Expect.equals("case-1", test2_1({false: true, true: true}));
70+
Expect.equals("case-1", test2_2({false: false, true: true}));
71+
}

0 commit comments

Comments
 (0)