| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // When attempting to call a nonexistent static method, getter or setter, check | 5 // When attempting to call a nonexistent static method, getter or setter, check |
| 6 // that a NoSuchMethodError is thrown. | 6 // that a NoSuchMethodError is thrown. |
| 7 | 7 |
| 8 class C {} | 8 class C {} |
| 9 | 9 |
| 10 class D { |
| 11 get hest => 1; /// 04: continued |
| 12 set hest(val) {} /// 05: continued |
| 13 } |
| 14 |
| 15 get fisk => 2; /// 09: continued |
| 16 set fisk(val) {} /// 10: continued |
| 17 |
| 18 expectNsme([void fun()]) { |
| 19 if (fun != null) { |
| 20 Expect.throws(fun, (e) => e is NoSuchMethodError); |
| 21 } |
| 22 } |
| 23 |
| 24 alwaysThrows() { |
| 25 throw new NoSuchMethodError(null, 'foo', []); |
| 26 } |
| 27 |
| 28 test01() { |
| 29 C.hest = 1; /// 01: static type warning |
| 30 } |
| 31 |
| 32 test02() { |
| 33 C.hest; /// 02: static type warning |
| 34 } |
| 35 |
| 36 test03() { |
| 37 C.hest(); /// 03: static type warning |
| 38 } |
| 39 |
| 40 test04() { |
| 41 D.hest = 1; /// 04: static type warning |
| 42 } |
| 43 |
| 44 test05() { |
| 45 D.hest; /// 05: static type warning |
| 46 } |
| 47 |
| 48 test06() { |
| 49 fisk = 1; /// 06: static type warning |
| 50 } |
| 51 |
| 52 test07() { |
| 53 fisk; /// 07: static type warning |
| 54 } |
| 55 |
| 56 test08() { |
| 57 fisk(); /// 08: static type warning |
| 58 } |
| 59 |
| 60 test09() { |
| 61 fisk = 1; /// 09: static type warning |
| 62 } |
| 63 |
| 64 test10() { |
| 65 fisk; /// 10: static type warning |
| 66 } |
| 67 |
| 10 main() { | 68 main() { |
| 11 Expect.throws(() => C.hest = 1, (e) => e is NoSuchMethodError); /// 01: static
type warning | 69 expectNsme(alwaysThrows); |
| 12 Expect.throws(() => C.hest, (e) => e is NoSuchMethodError); /// 02: static
type warning | 70 expectNsme( |
| 13 Expect.throws(() => C.hest(), (e) => e is NoSuchMethodError); /// 03: static
type warning | 71 test01 /// 01: continued |
| 72 ); |
| 73 expectNsme( |
| 74 test02 /// 02: continued |
| 75 ); |
| 76 expectNsme( |
| 77 test03 /// 03: continued |
| 78 ); |
| 79 expectNsme( |
| 80 test04 /// 04: continued |
| 81 ); |
| 82 expectNsme( |
| 83 test05 /// 05: continued |
| 84 ); |
| 85 expectNsme( |
| 86 test06 /// 06: continued |
| 87 ); |
| 88 expectNsme( |
| 89 test07 /// 07: continued |
| 90 ); |
| 91 expectNsme( |
| 92 test08 /// 08: continued |
| 93 ); |
| 94 expectNsme( |
| 95 test09 /// 09: continued |
| 96 ); |
| 97 expectNsme( |
| 98 test10 /// 10: continued |
| 99 ); |
| 14 } | 100 } |
| OLD | NEW |