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