| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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<T> { | 5 class A<T> { |
| 6 A() : x = null; | 6 A() : x = null; |
| 7 | 7 |
| 8 const A.constant(T x) : this.x = x; | 8 const A.constant(this.x); |
| 9 | 9 |
| 10 factory A.factory() { | 10 factory A.factory() { |
| 11 return new B<Set>(); | 11 return new B<Set>(); |
| 12 } | 12 } |
| 13 | 13 |
| 14 factory A.test01() = T; /// 01: runtime error |
| 15 |
| 16 factory A.test02() = Dynamic; /// 02: runtime error |
| 17 |
| 18 factory A.test03() = Undefined; /// 03: runtime error |
| 19 |
| 20 factory A.test04() = C.test04; /// 04: compile-time error |
| 21 |
| 14 final T x; | 22 final T x; |
| 15 } | 23 } |
| 16 | 24 |
| 17 class B<T> extends A<T> { | 25 class B<T> extends A<T> { |
| 18 B(); | 26 B(); |
| 19 | 27 |
| 20 factory B.A() = A<T>; | 28 factory B.A() = A<T>; |
| 21 | 29 |
| 22 const factory B.A_constant(T x) = A<T>.constant; | 30 const factory B.A_constant(T x) = A<T>.constant; |
| 23 | 31 |
| 24 factory B.A_factory() = A<T>.factory; | 32 factory B.A_factory() = A<T>.factory; |
| 33 |
| 34 factory B.test04() = A.test04; /// 04: continued |
| 35 |
| 36 factory B.test05(int incompatible) = A<T>.factory; /// 05: runtime error |
| 25 } | 37 } |
| 26 | 38 |
| 27 class C<K, V> extends B<V> { | 39 class C<K, V> extends B<V> { |
| 28 C(); | 40 C(); |
| 29 | 41 |
| 30 factory C.A() = A<V>; | 42 factory C.A() = A<V>; |
| 31 | 43 |
| 32 factory C.A_factory() = A<V>.factory; | 44 factory C.A_factory() = A<V>.factory; |
| 33 | 45 |
| 34 const factory C.B_constant(V x) = B<V>.A_constant; | 46 const factory C.B_constant(V x) = B<V>.A_constant; |
| 47 |
| 48 factory C.test04() = B.test04; /// 04: continued |
| 49 |
| 50 factory C.test06(int incompatible) = B<K>.test05; /// 06: runtime error |
| 51 |
| 52 const factory C.test07(V x) = B<V>.A; /// 07: compile-time error |
| 35 } | 53 } |
| 36 | 54 |
| 37 main() { | 55 main() { |
| 56 new A<List>.test01(); /// 01: continued |
| 57 new A<List>.test02(); /// 02: continued |
| 58 new A<List>.test03(); /// 03: continued |
| 59 new C.test04(); /// 04: continued |
| 60 new B.test05(0); /// 05: continued |
| 61 new C.test06<int, int>(0); /// 06: continued |
| 62 new C.test07<int, int>(0); /// 07: continued |
| 38 Expect.isTrue(new A<List>() is A<List>); | 63 Expect.isTrue(new A<List>() is A<List>); |
| 39 Expect.isTrue(new A<bool>.constant(true).x); | 64 Expect.isTrue(new A<bool>.constant(true).x); |
| 40 Expect.isTrue(new A<List>.factory() is B<Set>); | 65 Expect.isTrue(new A<List>.factory() is B<Set>); |
| 41 Expect.isTrue(new B<List>.A() is A<List>); | 66 Expect.isTrue(new B<List>.A() is A<List>); |
| 42 Expect.isTrue(new B<bool>.A_constant(true).x); | 67 Expect.isTrue(new B<bool>.A_constant(true).x); |
| 43 Expect.isTrue(new B<List>.A_factory() is B<Set>); | 68 Expect.isTrue(new B<List>.A_factory() is B<Set>); |
| 44 Expect.isTrue(new C<String, num>.A() is A<num>); | 69 Expect.isTrue(new C<String, num>.A() is A<num>); |
| 45 Expect.isTrue(new C<String, num>.A_factory() is B<Set>); | 70 Expect.isTrue(new C<String, num>.A_factory() is B<Set>); |
| 46 Expect.isTrue(new C<String, bool>.B_constant(true).x); | 71 Expect.isTrue(new C<String, bool>.B_constant(true).x); |
| 47 } | 72 } |
| OLD | NEW |