Chromium Code Reviews| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 bool get inCheckedMode { | 7 bool get inCheckedMode { |
| 8 try { | 8 try { |
| 9 String a = 42; | 9 String a = 42; /// 01: static type warning |
|
kasperl
2013/11/06 14:26:13
You could also just do:
var i = 42;
String a
ngeoffray
2013/11/06 14:37:32
Done.
| |
| 10 } catch (e) { | 10 } catch (e) { |
| 11 return true; | 11 return true; |
| 12 } | 12 } |
| 13 return false; | 13 return false; |
| 14 } | 14 } |
| 15 | 15 |
| 16 class A<T> { | 16 class A<T> { |
| 17 T field; | 17 T field; |
| 18 } | 18 } |
| 19 | 19 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 31 if (inCheckedMode) { | 31 if (inCheckedMode) { |
| 32 Expect.throws(() => a.field = 42, (e) => e is TypeError); | 32 Expect.throws(() => a.field = 42, (e) => e is TypeError); |
| 33 Expect.throws(() => new B<String>(), (e) => e is TypeError); | 33 Expect.throws(() => new B<String>(), (e) => e is TypeError); |
| 34 Expect.throws(() => c.field = 'foo', (e) => e is TypeError); | 34 Expect.throws(() => c.field = 'foo', (e) => e is TypeError); |
| 35 } else { | 35 } else { |
| 36 a.field = 42; | 36 a.field = 42; |
| 37 new B<String>(); | 37 new B<String>(); |
| 38 c.field = 'foo'; | 38 c.field = 'foo'; |
| 39 } | 39 } |
| 40 } | 40 } |
| OLD | NEW |