Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: pkg/front_end/testcases/inference/infer_assign_to_property_upwards.dart

Issue 2931363003: Add type inference for assignments to properties. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017, 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 /*@testedFeatures=inference*/
6 library test;
7
8 int getInt() => 0;
9 num getNum() => 0;
10 double getDouble() => 0.0;
11
12 class Test1 {
13 int prop;
14
15 static void test(Test1 t) {
16 var /*@type=int*/ v1 = t. /*@target=Test1::prop*/ prop = getInt();
17 var /*@type=num*/ v2 = t. /*@target=Test1::prop*/ prop = getNum();
18 var /*@type=int*/ v4 = t. /*@target=Test1::prop*/ prop ??= getInt();
19 var /*@type=num*/ v5 = t. /*@target=Test1::prop*/ prop ??= getNum();
20 var /*@type=int*/ v7 = t. /*@target=Test1::prop*/ prop += getInt();
21 var /*@type=num*/ v8 = t. /*@target=Test1::prop*/ prop += getNum();
22 var /*@type=int*/ v10 = ++t. /*@target=Test1::prop*/ prop;
23 var /*@type=int*/ v11 = t. /*@target=Test1::prop*/ prop++;
24 }
25 }
26
27 class Test2 {
28 num prop;
29
30 static void test(Test2 t) {
31 var /*@type=int*/ v1 = t. /*@target=Test2::prop*/ prop = getInt();
32 var /*@type=num*/ v2 = t. /*@target=Test2::prop*/ prop = getNum();
33 var /*@type=double*/ v3 = t. /*@target=Test2::prop*/ prop = getDouble();
34 var /*@type=num*/ v4 = t. /*@target=Test2::prop*/ prop ??= getInt();
35 var /*@type=num*/ v5 = t. /*@target=Test2::prop*/ prop ??= getNum();
36 var /*@type=num*/ v6 = t. /*@target=Test2::prop*/ prop ??= getDouble();
37 var /*@type=num*/ v7 = t. /*@target=Test2::prop*/ prop += getInt();
38 var /*@type=num*/ v8 = t. /*@target=Test2::prop*/ prop += getNum();
39 var /*@type=num*/ v9 = t. /*@target=Test2::prop*/ prop += getDouble();
40 var /*@type=num*/ v10 = ++t. /*@target=Test2::prop*/ prop;
41 var /*@type=num*/ v11 = t. /*@target=Test2::prop*/ prop++;
42 }
43 }
44
45 class Test3 {
46 double prop;
47
48 static void test3(Test3 t) {
49 var /*@type=num*/ v2 = t. /*@target=Test3::prop*/ prop = getNum();
50 var /*@type=double*/ v3 = t. /*@target=Test3::prop*/ prop = getDouble();
51 var /*@type=num*/ v5 = t. /*@target=Test3::prop*/ prop ??= getNum();
52 var /*@type=double*/ v6 = t. /*@target=Test3::prop*/ prop ??= getDouble();
53 var /*@type=double*/ v7 = t. /*@target=Test3::prop*/ prop += getInt();
54 var /*@type=double*/ v8 = t. /*@target=Test3::prop*/ prop += getNum();
55 var /*@type=double*/ v9 = t. /*@target=Test3::prop*/ prop += getDouble();
56 var /*@type=double*/ v10 = ++t. /*@target=Test3::prop*/ prop;
57 var /*@type=double*/ v11 = t. /*@target=Test3::prop*/ prop++;
58 }
59 }
60
61 main() {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698