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 class A { | 5 class A { |
6 const A(); | 6 const A(); |
7 } | 7 } |
8 | 8 |
9 class B extends A { | 9 class B extends A { |
10 const B(); | 10 const B(); |
11 } | 11 } |
12 | 12 |
13 class C extends A { | 13 class C extends A { |
14 const C(); | 14 const C(); |
15 const factory C.d() = D; | 15 const factory C.d() = D; |
16 } | 16 } |
17 | 17 |
18 class D extends B implements C { | 18 class D extends B implements C { |
19 const D(); | 19 const D(); |
20 } | 20 } |
21 | 21 |
22 class Test1 { | 22 class Test1 { |
23 final A x = const A(); /// 01: ok | 23 final A x = const A(); //# 01: ok |
24 final A x = const B(); /// 02: ok | 24 final A x = const B(); //# 02: ok |
25 final B x = const A(); /// 03: checked mode compile-time error | 25 final B x = const A(); //# 03: checked mode compile-time error |
26 final B x = const C(); /// 04: checked mode compile-time error, static type wa
rning | 26 final B x = const C(); //# 04: checked mode compile-time error, static type wa
rning |
27 final B x = const C.d(); /// 05: static type warning | 27 final B x = const C.d(); //# 05: static type warning |
28 const Test1(); | 28 const Test1(); |
29 } | 29 } |
30 | 30 |
31 // Will be instantiated with U=A and V=B. | 31 // Will be instantiated with U=A and V=B. |
32 class Test2<U, V> { | 32 class Test2<U, V> { |
33 final U x = const A(); /// 06: static type warning | 33 final U x = const A(); //# 06: static type warning |
34 final U x = const B(); /// 07: static type warning | 34 final U x = const B(); //# 07: static type warning |
35 final V x = const A(); /// 08: checked mode compile-time error, static type wa
rning | 35 final V x = const A(); //# 08: checked mode compile-time error, static type wa
rning |
36 final V x = const C(); /// 09: checked mode compile-time error, static type wa
rning | 36 final V x = const C(); //# 09: checked mode compile-time error, static type wa
rning |
37 final V x = const C.d(); /// 10: static type warning | 37 final V x = const C.d(); //# 10: static type warning |
38 const Test2(); | 38 const Test2(); |
39 } | 39 } |
40 | 40 |
41 // Will be instantiated with U=A and V=B. | 41 // Will be instantiated with U=A and V=B. |
42 class Test3<U extends A, V extends B> { | 42 class Test3<U extends A, V extends B> { |
43 final U x = const A(); /// 11: ok | 43 final U x = const A(); //# 11: ok |
44 final U x = const B(); /// 12: static type warning | 44 final U x = const B(); //# 12: static type warning |
45 final V x = const A(); /// 13: checked mode compile-time error | 45 final V x = const A(); //# 13: checked mode compile-time error |
46 final V x = const C(); /// 14: checked mode compile-time error, static type wa
rning | 46 final V x = const C(); //# 14: checked mode compile-time error, static type wa
rning |
47 final V x = const C.d(); /// 15: static type warning | 47 final V x = const C.d(); //# 15: static type warning |
48 const Test3(); | 48 const Test3(); |
49 } | 49 } |
50 | 50 |
51 // Will be instantiated with U=A and V=B. | 51 // Will be instantiated with U=A and V=B. |
52 class Test4<U extends A, V extends A> { | 52 class Test4<U extends A, V extends A> { |
53 final U x = const A(); /// 16: ok | 53 final U x = const A(); //# 16: ok |
54 final U x = const B(); /// 17: static type warning | 54 final U x = const B(); //# 17: static type warning |
55 final V x = const A(); /// 18: checked mode compile-time error | 55 final V x = const A(); //# 18: checked mode compile-time error |
56 final V x = const C(); /// 19: checked mode compile-time error, static type wa
rning | 56 final V x = const C(); //# 19: checked mode compile-time error, static type wa
rning |
57 final V x = const C.d(); /// 20: static type warning | 57 final V x = const C.d(); //# 20: static type warning |
58 const Test4(); | 58 const Test4(); |
59 } | 59 } |
60 | 60 |
61 // Will be instantiated with U=dynamic and V=dynamic. | 61 // Will be instantiated with U=dynamic and V=dynamic. |
62 class Test5<U extends A, V extends B> { | 62 class Test5<U extends A, V extends B> { |
63 final U x = const A(); /// 21: ok | 63 final U x = const A(); //# 21: ok |
64 final U x = const B(); /// 22: static type warning | 64 final U x = const B(); //# 22: static type warning |
65 final V x = const A(); /// 23: ok | 65 final V x = const A(); //# 23: ok |
66 final V x = const C(); /// 24: static type warning | 66 final V x = const C(); //# 24: static type warning |
67 final V x = const C.d(); /// 25: static type warning | 67 final V x = const C.d(); //# 25: static type warning |
68 const Test5(); | 68 const Test5(); |
69 } | 69 } |
70 | 70 |
71 use(x) => x; | 71 use(x) => x; |
72 | 72 |
73 main() { | 73 main() { |
74 use(const Test1()); | 74 use(const Test1()); |
75 use(const Test2<A, B>()); | 75 use(const Test2<A, B>()); |
76 use(const Test3<A, B>()); | 76 use(const Test3<A, B>()); |
77 use(const Test4<A, B>()); | 77 use(const Test4<A, B>()); |
78 use(const Test5()); | 78 use(const Test5()); |
79 } | 79 } |
OLD | NEW |