OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /*@testedFeatures=inference*/ | 5 /*@testedFeatures=inference*/ |
6 library test; | 6 library test; |
7 | 7 |
8 class A { | 8 class A { |
9 int x = 0; | 9 int x = 0; |
10 | 10 |
11 test1() { | 11 test1() { |
12 var /*@type=int*/ a = x; | 12 var /*@type=int*/ a = /*@target=A::x*/ x; |
13 a = /*error:INVALID_ASSIGNMENT*/ "hi"; | 13 a = /*error:INVALID_ASSIGNMENT*/ "hi"; |
14 a = 3; | 14 a = 3; |
15 var /*@type=int*/ b = y; | 15 var /*@type=int*/ b = /*@target=A::y*/ y; |
16 b = /*error:INVALID_ASSIGNMENT*/ "hi"; | 16 b = /*error:INVALID_ASSIGNMENT*/ "hi"; |
17 b = 4; | 17 b = 4; |
18 var /*@type=int*/ c = z; | 18 var /*@type=int*/ c = /*@target=A::z*/ z; |
19 c = /*error:INVALID_ASSIGNMENT*/ "hi"; | 19 c = /*error:INVALID_ASSIGNMENT*/ "hi"; |
20 c = 4; | 20 c = 4; |
21 } | 21 } |
22 | 22 |
23 int y; // field def after use | 23 int y; // field def after use |
24 final /*@topType=int*/ z = 42; // should infer `int` | 24 final /*@topType=int*/ z = 42; // should infer `int` |
25 } | 25 } |
OLD | NEW |