OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // Test that we emit warnings for unresolved indexing operations on super. | 5 // Test that we emit warnings for unresolved indexing operations on super. |
6 | 6 |
7 class A { | 7 class A { |
8 operator[]=(a, b) {} | 8 operator[]=(a, b) {} |
9 } | 9 } |
10 | 10 |
11 class B extends A { | 11 class B extends A { |
12 foo() { | 12 foo() { |
13 super[4] = 42; | 13 super[4] = 42; |
14 super[4] += 5; /// 01: static type warning, runtime error | 14 super[4] += 5; //# 01: static type warning, runtime error |
15 return super[2]; /// 02: static type warning, runtime error | 15 return super[2]; //# 02: static type warning, runtime error |
16 } | 16 } |
17 } | 17 } |
18 | 18 |
19 class C { | 19 class C { |
20 operator[](a) {} | 20 operator[](a) {} |
21 } | 21 } |
22 | 22 |
23 class D extends C { | 23 class D extends C { |
24 foo() { | 24 foo() { |
25 super[4] = 42; /// 03: static type warning, runtime error | 25 super[4] = 42; //# 03: static type warning, runtime error |
26 super[4] += 5; /// 04: static type warning, runtime error | 26 super[4] += 5; //# 04: static type warning, runtime error |
27 return super[2]; | 27 return super[2]; |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 class E { | 31 class E { |
32 foo() { | 32 foo() { |
33 super[4] = 42; /// 05: static type warning, runtime error | 33 super[4] = 42; //# 05: static type warning, runtime error |
34 super[4] += 5; /// 06: static type warning, runtime error | 34 super[4] += 5; //# 06: static type warning, runtime error |
35 return super[2]; /// 07: static type warning, runtime error | 35 return super[2]; //# 07: static type warning, runtime error |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 main() { | 39 main() { |
40 new B().foo(); | 40 new B().foo(); |
41 new D().foo(); | 41 new D().foo(); |
42 new E().foo(); | 42 new E().foo(); |
43 } | 43 } |
OLD | NEW |