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 // Regression test for a crash in dart2js. | 5 // Regression test for a crash in dart2js. |
6 | 6 |
7 library crash_6725; | 7 class Fisk { |
| 8 it1(x) { |
| 9 // "key" is unresolved and caused a crash in dart2js. |
| 10 // This is the original example the user reported. |
| 11 for (key in x) { |
| 12 print(key); |
| 13 } |
| 14 } |
8 | 15 |
9 part 'crash_6725_part.dart'; /// 01: static type warning | 16 it2(x) { |
| 17 // "length" is "intercepted" and handled differently from other |
| 18 // names when an instance of list is observed. |
| 19 for (length in x) { |
| 20 print(length); |
| 21 } |
| 22 } |
| 23 |
| 24 it3(x) { |
| 25 // We're pretty sure that there's no "fisk" that is "intercepted". |
| 26 for (fisk in x) { |
| 27 print(fisk); |
| 28 } |
| 29 } |
| 30 } |
| 31 |
| 32 class SubFisk extends Fisk { |
| 33 var key; |
| 34 var length; |
| 35 var fisk; |
| 36 } |
10 | 37 |
11 main() { | 38 main() { |
12 test(); /// 01: continued | 39 Fisk f = new SubFisk(); |
| 40 var m = (x) { |
| 41 for (undeclared in x) { |
| 42 print(undeclared); |
| 43 } |
| 44 }; |
| 45 if (new DateTime.now().millisecondsSinceEpoch == 42) { |
| 46 f = null; |
| 47 m = (x) {}; |
| 48 } |
| 49 |
| 50 f.it1([87, 42]); |
| 51 if (f.key != 42) { |
| 52 throw 'f.key != 42 (${f.key})'; |
| 53 } |
| 54 |
| 55 f.it2([87, 42]); |
| 56 if (f.length != 42) { |
| 57 throw 'f.length != 42 (${f.length})'; |
| 58 } |
| 59 |
| 60 f.it3([87, 42]); |
| 61 if (f.fisk != 42) { |
| 62 throw 'f.fisk != 42 (${f.fisk})'; |
| 63 } |
| 64 |
| 65 try { |
| 66 m([87, 42]); |
| 67 throw 'NoSuchMethodError expected'; |
| 68 } on NoSuchMethodError { |
| 69 // Expected. |
| 70 } |
13 } | 71 } |
OLD | NEW |