OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 String toplevel = 'A'; | 7 String toplevel = 'A'; |
8 | 8 |
9 class Foo { | 9 class Foo { |
10 String x = 'x'; | 10 String x = 'x'; |
11 | 11 |
12 easy(z) { | 12 easy(z) { |
13 return x + y + z; /// 01: static type warning | 13 return x + y + z; //# 01: static type warning |
14 } | 14 } |
15 | 15 |
16 // Shadow the 'y' field in various ways | 16 // Shadow the 'y' field in various ways |
17 shadow_y_parameter(y) { | 17 shadow_y_parameter(y) { |
18 return x + this.y + y; /// 01: continued | 18 return x + this.y + y; //# 01: continued |
19 } | 19 } |
20 | 20 |
21 shadow_y_local(z) { | 21 shadow_y_local(z) { |
22 var y = z; | 22 var y = z; |
23 return x + this.y + y; /// 01: continued | 23 return x + this.y + y; //# 01: continued |
24 } | 24 } |
25 | 25 |
26 shadow_y_capturedLocal(z) { | 26 shadow_y_capturedLocal(z) { |
27 var y = z; | 27 var y = z; |
28 foo() { | 28 foo() { |
29 return x + this.y + y; /// 01: continued | 29 return x + this.y + y; //# 01: continued |
30 } | 30 } |
31 return foo(); | 31 return foo(); |
32 } | 32 } |
33 | 33 |
34 shadow_y_closureParam(z) { | 34 shadow_y_closureParam(z) { |
35 foo(y) { | 35 foo(y) { |
36 return x + this.y + y; /// 01: continued | 36 return x + this.y + y; //# 01: continued |
37 } | 37 } |
38 return foo(z); | 38 return foo(z); |
39 } | 39 } |
40 | 40 |
41 shadow_y_localInsideClosure(z) { | 41 shadow_y_localInsideClosure(z) { |
42 foo() { | 42 foo() { |
43 var y = z; | 43 var y = z; |
44 return x + this.y + y; /// 01: continued | 44 return x + this.y + y; //# 01: continued |
45 } | 45 } |
46 return foo(); | 46 return foo(); |
47 } | 47 } |
48 | 48 |
49 // Shadow the 'x' field in various ways | 49 // Shadow the 'x' field in various ways |
50 shadow_x_parameter(x) { | 50 shadow_x_parameter(x) { |
51 return this.x + y + x; /// 01: continued | 51 return this.x + y + x; //# 01: continued |
52 } | 52 } |
53 | 53 |
54 shadow_x_local(z) { | 54 shadow_x_local(z) { |
55 var x = z; | 55 var x = z; |
56 return this.x + y + x; /// 01: continued | 56 return this.x + y + x; //# 01: continued |
57 } | 57 } |
58 | 58 |
59 shadow_x_capturedLocal(z) { | 59 shadow_x_capturedLocal(z) { |
60 var x = z; | 60 var x = z; |
61 foo() { | 61 foo() { |
62 return this.x + y + x; /// 01: continued | 62 return this.x + y + x; //# 01: continued |
63 } | 63 } |
64 return foo(); | 64 return foo(); |
65 } | 65 } |
66 | 66 |
67 shadow_x_closureParam(z) { | 67 shadow_x_closureParam(z) { |
68 foo(x) { | 68 foo(x) { |
69 return this.x + y + x; /// 01: continued | 69 return this.x + y + x; //# 01: continued |
70 } | 70 } |
71 return foo(z); | 71 return foo(z); |
72 } | 72 } |
73 | 73 |
74 shadow_x_localInsideClosure(z) { | 74 shadow_x_localInsideClosure(z) { |
75 foo() { | 75 foo() { |
76 var x = z; | 76 var x = z; |
77 return this.x + y + x; /// 01: continued | 77 return this.x + y + x; //# 01: continued |
78 } | 78 } |
79 return foo(); | 79 return foo(); |
80 } | 80 } |
81 | 81 |
82 shadow_x_toplevel() { | 82 shadow_x_toplevel() { |
83 return x + this.y + toplevel + this.toplevel; /// 01: continued | 83 return x + this.y + toplevel + this.toplevel; //# 01: continued |
84 } | 84 } |
85 | 85 |
86 } | 86 } |
87 | 87 |
88 class Sub extends Foo { | 88 class Sub extends Foo { |
89 String y = 'y'; | 89 String y = 'y'; |
90 String toplevel = 'B'; | 90 String toplevel = 'B'; |
91 } | 91 } |
92 | 92 |
93 main() { | 93 main() { |
94 Expect.equals('xyz', new Sub().easy('z')); /// 01: continued | 94 Expect.equals('xyz', new Sub().easy('z')); //# 01: continued |
95 Expect.equals('xyz', new Sub().shadow_y_parameter('z')); /// 01: continued | 95 Expect.equals('xyz', new Sub().shadow_y_parameter('z')); //# 01: continued |
96 Expect.equals('xyz', new Sub().shadow_y_local('z')); /// 01: continued | 96 Expect.equals('xyz', new Sub().shadow_y_local('z')); //# 01: continued |
97 Expect.equals('xyz', new Sub().shadow_y_capturedLocal('z')); /// 01: continu
ed | 97 Expect.equals('xyz', new Sub().shadow_y_capturedLocal('z')); //# 01: continu
ed |
98 Expect.equals('xyz', new Sub().shadow_y_closureParam('z')); /// 01: continue
d | 98 Expect.equals('xyz', new Sub().shadow_y_closureParam('z')); //# 01: continue
d |
99 Expect.equals('xyz', new Sub().shadow_y_localInsideClosure('z')); /// 01: co
ntinued | 99 Expect.equals('xyz', new Sub().shadow_y_localInsideClosure('z')); //# 01: co
ntinued |
100 Expect.equals('xyz', new Sub().shadow_x_parameter('z')); /// 01: continued | 100 Expect.equals('xyz', new Sub().shadow_x_parameter('z')); //# 01: continued |
101 Expect.equals('xyz', new Sub().shadow_x_local('z')); /// 01: continued | 101 Expect.equals('xyz', new Sub().shadow_x_local('z')); //# 01: continued |
102 Expect.equals('xyz', new Sub().shadow_x_capturedLocal('z')); /// 01: continu
ed | 102 Expect.equals('xyz', new Sub().shadow_x_capturedLocal('z')); //# 01: continu
ed |
103 Expect.equals('xyz', new Sub().shadow_x_closureParam('z')); /// 01: continue
d | 103 Expect.equals('xyz', new Sub().shadow_x_closureParam('z')); //# 01: continue
d |
104 Expect.equals('xyz', new Sub().shadow_x_localInsideClosure('z')); /// 01: co
ntinued | 104 Expect.equals('xyz', new Sub().shadow_x_localInsideClosure('z')); //# 01: co
ntinued |
105 | 105 |
106 Expect.equals('xyAB', new Sub().shadow_x_toplevel()); /// 01: continued | 106 Expect.equals('xyAB', new Sub().shadow_x_toplevel()); //# 01: continued |
107 } | 107 } |
OLD | NEW |