|
5 | 5 | /// @assertion The lifted space union for a pattern with matched value type M is
|
6 | 6 | /// ...
|
7 | 7 | /// Cast pattern:
|
8 |
| -/// The space union spaces for a cast pattern with cast type C is a union of: |
9 |
| -/// - The lifted space union of the cast's subpattern in context C. |
10 |
| -/// - For each space E in the expanded spaces of M: |
11 |
| -/// a. If E is not a subset of C and C is not a subset of M, then the lifted |
12 |
| -/// space union of E. |
| 8 | +/// ... |
| 9 | +/// Let S be the lifted space union of the cast's subpattern in context C. |
| 10 | +/// i. If C is a subset (see below about type subsetting) of S then the result |
| 11 | +/// spaces is the lifted space union of M. |
| 12 | +/// ii. Otherwise, the result spaces is S plus the lifted space union of Null |
| 13 | +/// when C is a non-nullable type, and spaces is S when C is potentially |
| 14 | +/// nullable. |
13 | 15 | ///
|
14 | 16 | /// @description Check a lifted space of a cast pattern in case of not sealed
|
15 | 17 | /// type. Test switch element
|
16 | 18 | /// @author sgrekhov22@gmail.com
|
17 | 19 | /// @issue 51986
|
18 | 20 |
|
19 |
| -import "../../../Utils/expect.dart"; |
20 |
| - |
| 21 | +// The corresponding switch statement (can be found in |
| 22 | +// `lifting_cast_pattern_A01_t01.dart`) will not complete normally in this case |
| 23 | +// (which means that there is no "returns null" error), but this switch |
| 24 | +// expression is an error because it can not be recognized as exhaustive. This |
| 25 | +// discrepancy is expected. For more details see |
| 26 | +// https://github.com/dart-lang/sdk/issues/51986#issuecomment-1864237801 |
21 | 27 | int test(Object obj) => switch (obj) {
|
| 28 | +// ^^^^^^ |
| 29 | +// [analyzer] unspecified |
| 30 | +// [cfe] unspecified |
22 | 31 | int(isEven: true) as int => 1,
|
23 | 32 | int _ => 2
|
24 | 33 | };
|
25 | 34 |
|
26 | 35 | main() {
|
27 |
| - Expect.equals(2 ,test(1)); |
28 |
| - Expect.equals(1 ,test(2)); |
| 36 | + print(test); |
29 | 37 | }
|
0 commit comments