OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 class A { |
| 6 const A(); |
| 7 } |
| 8 |
| 9 class B extends A { |
| 10 const B(); |
| 11 } |
| 12 |
| 13 class C extends A { |
| 14 const C(); |
| 15 const factory C.d() = D; |
| 16 } |
| 17 |
| 18 class D extends B implements C { |
| 19 const D(); |
| 20 } |
| 21 |
| 22 class Test1 { |
| 23 final A x = const A(); /// 01: ok |
| 24 final A x = const B(); /// 02: ok |
| 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 |
| 27 final B x = const C.d(); /// 05: static type warning |
| 28 const Test1(); |
| 29 } |
| 30 |
| 31 // Will be instantiated with U=A and V=B. |
| 32 class Test2<U, V> { |
| 33 final U x = const A(); /// 06: 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 |
| 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 |
| 38 const Test2(); |
| 39 } |
| 40 |
| 41 // Will be instantiated with U=A and V=B. |
| 42 class Test3<U extends A, V extends B> { |
| 43 final U x = const A(); /// 11: ok |
| 44 final U x = const B(); /// 12: static type warning |
| 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 |
| 47 final V x = const C.d(); /// 15: static type warning |
| 48 const Test3(); |
| 49 } |
| 50 |
| 51 // Will be instantiated with U=A and V=B. |
| 52 class Test4<U extends A, V extends A> { |
| 53 final U x = const A(); /// 16: ok |
| 54 final U x = const B(); /// 17: static type warning |
| 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 |
| 57 final V x = const C.d(); /// 20: static type warning |
| 58 const Test4(); |
| 59 } |
| 60 |
| 61 // Will be instantiated with U=dynamic and V=dynamic. |
| 62 class Test5<U extends A, V extends B> { |
| 63 final U x = const A(); /// 21: ok |
| 64 final U x = const B(); /// 22: static type warning |
| 65 final V x = const A(); /// 23: ok |
| 66 final V x = const C(); /// 24: static type warning |
| 67 final V x = const C.d(); /// 25: static type warning |
| 68 const Test5(); |
| 69 } |
| 70 |
| 71 use(x) => x; |
| 72 |
| 73 main() { |
| 74 use(const Test1()); |
| 75 use(const Test2<A, B>()); |
| 76 use(const Test3<A, B>()); |
| 77 use(const Test4<A, B>()); |
| 78 use(const Test5()); |
| 79 } |
OLD | NEW |