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 // Dart test program for constructors and initializers. | 4 // Dart test program for constructors and initializers. |
5 | 5 |
6 // Check function subtyping of static functions. | 6 // Check function subtyping of static functions. |
7 | 7 |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 typedef I<T> f2<T>(); | 10 typedef I<T> f2<T>(); |
11 | 11 |
12 class X { | 12 class X { |
13 static J<bool> f1() => null; | 13 static J<bool> f1() => null; |
14 } | 14 } |
15 | 15 |
16 class C<T> { | 16 class C<T> { |
17 C(f2<T> f); | 17 C(f2<T> f); |
18 } | 18 } |
19 | 19 |
20 class I<T> {} | 20 class I<T> {} |
| 21 |
21 class J<T> extends I<int> {} | 22 class J<T> extends I<int> {} |
22 | 23 |
23 main() { | 24 main() { |
24 | |
25 bool inCheckedMode = false; | 25 bool inCheckedMode = false; |
26 try { | 26 try { |
27 String a = 42; | 27 String a = 42; |
28 } catch (e) { | 28 } catch (e) { |
29 inCheckedMode = true; | 29 inCheckedMode = true; |
30 } | 30 } |
31 | 31 |
32 new C<int>(X.f1); | 32 new C<int>(X.f1); |
33 if (inCheckedMode) { | 33 if (inCheckedMode) { |
34 Expect.throws(() => new C<bool>(X.f1), (e) => true); | 34 Expect.throws(() => new C<bool>(X.f1), (e) => true); |
35 } | 35 } |
36 } | 36 } |
OLD | NEW |