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