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 isCheckedMode() { | 7 isCheckedMode() { |
8 try { | 8 try { |
9 var i = 1; | 9 var i = 1; |
10 String s = i; | 10 String s = i; |
11 return false; | 11 return false; |
12 } catch (e) { | 12 } catch (e) { |
13 return true; | 13 return true; |
14 } | 14 } |
15 } | 15 } |
16 | 16 |
17 class A<T extends num> { } | 17 class A<T extends num> { } |
18 | 18 |
19 class B<T> { | 19 class B<T> { |
20 test() { | 20 test() { |
21 new A() is A<T>; // /// static type warning | 21 new A() is A<T>; // //# static type warning |
22 } | 22 } |
23 } | 23 } |
24 | 24 |
25 main () { | 25 main () { |
26 var b = new B<String>(); | 26 var b = new B<String>(); |
27 if (isCheckedMode()) { | 27 if (isCheckedMode()) { |
28 Expect.throws(() => b.test(), (e) => e is TypeError); | 28 Expect.throws(() => b.test(), (e) => e is TypeError); |
29 } else { | 29 } else { |
30 b.test(); | 30 b.test(); |
31 } | 31 } |
32 } | 32 } |
OLD | NEW |