File tree Expand file tree Collapse file tree 2 files changed +39
-3
lines changed
LanguageFeatures/Patterns Expand file tree Collapse file tree 2 files changed +39
-3
lines changed Original file line number Diff line number Diff line change
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
6
+ /// The context type schema for a pattern p is:
7
+ /// ...
8
+ /// Identifier:
9
+ /// In an assignment context, the context type schema is the static type of the
10
+ /// variable that p resolves to.
11
+ ///
12
+ /// Else the context type schema is _
13
+ ///
14
+ /// @description Check that in an assignment context, the context type schema is
15
+ /// the static type of the variable that p resolves to. Test promoted type
16
+
17
+
18
+ // SharedOptions=--enable-experiment=patterns,records
19
+
20
+ main () {
21
+ num a = 0 ;
22
+ a as int ;
23
+ a.isEven;
24
+ [a] = [3.14 ]; // [a] infers <int>[3.14] to right hand expression
25
+ // ^^^^
26
+ // [analyzer] unspecified
27
+ // [cfe] unspecified
28
+
29
+ var c = 2 > 1 ? 42 : 3.14 ;
30
+ c as int ;
31
+ c.isEven;
32
+ {"key1" : c} = {"key1" : 3.14 };
33
+ // ^^^^
34
+ // [analyzer] unspecified
35
+ // [cfe] unspecified
36
+ }
Original file line number Diff line number Diff line change @@ -28,19 +28,19 @@ main() {
28
28
num a = 0 ;
29
29
a as int ;
30
30
a.isEven;
31
- [a] = [3.14 ];
31
+ [a] = < double > [3.14 ];
32
32
a.expectStaticType <Exactly <num >>();
33
33
34
34
var (num b,) = (0 ,);
35
35
b as int ;
36
36
b.isEven;
37
37
(b,) = (3.14 ,);
38
- b .expectStaticType <Exactly <num >>();
38
+ a .expectStaticType <Exactly <num >>();
39
39
40
40
var c = 2 > 1 ? 42 : 3.14 ;
41
41
c.expectStaticType <Exactly <num >>();
42
42
c as int ;
43
43
c.isEven;
44
- {"key1" : c} = {"key1" : 3.14 };
44
+ {"key1" : c} = < String , double > {"key1" : 3.14 };
45
45
c.expectStaticType <Exactly <num >>();
46
46
}
You can’t perform that action at this time.
0 commit comments