Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 class A<T> { | |
| 6 A() : x = null; | |
| 7 | |
| 8 const A.constant(T x) : this.x = x; | |
|
siva
2012/09/24 20:51:35
const A.constant(this.x); ?
regis
2012/09/24 21:41:28
Done.
| |
| 9 | |
| 10 factory A.factory() { | |
| 11 return new B<Set>(); | |
| 12 } | |
| 13 | |
| 14 final T x; | |
| 15 } | |
| 16 | |
| 17 class B<T> extends A<T> { | |
| 18 B(); | |
| 19 | |
| 20 factory B.A() = A<T>; | |
| 21 | |
| 22 const factory B.A_constant(T x) = A<T>.constant; | |
| 23 | |
| 24 factory B.A_factory() = A<T>.factory; | |
| 25 } | |
| 26 | |
| 27 class C<K, V> extends B<V> { | |
| 28 C(); | |
| 29 | |
| 30 factory C.A() = A<V>; | |
| 31 | |
| 32 factory C.A_factory() = A<V>.factory; | |
|
siva
2012/09/24 20:51:35
Would it be legal here to redirect to A<K>.factory
regis
2012/09/24 21:41:28
Yes, it would. But you would need to call new C<bo
| |
| 33 | |
| 34 const factory C.B_constant(V x) = B<V>.A_constant; | |
| 35 } | |
| 36 | |
| 37 main() { | |
| 38 Expect.isTrue(new A<List>() is A<List>); | |
| 39 Expect.isTrue(new A<bool>.constant(true).x); | |
| 40 Expect.isTrue(new A<List>.factory() is B<Set>); | |
| 41 Expect.isTrue(new B<List>.A() is A<List>); | |
| 42 Expect.isTrue(new B<bool>.A_constant(true).x); | |
| 43 Expect.isTrue(new B<List>.A_factory() is B<Set>); | |
| 44 Expect.isTrue(new C<String, num>.A() is A<num>); | |
| 45 Expect.isTrue(new C<String, num>.A_factory() is B<Set>); | |
| 46 Expect.isTrue(new C<String, bool>.B_constant(true).x); | |
| 47 } | |
| OLD | NEW |