| OLD | NEW |
| 1 // Copyright (c) 2011, 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 // Dart test program for testing factories. | 4 |
| 5 // Dart test program for testing default keyword on interfaces |
| 6 // Test case for issues 500 and 512 |
| 5 | 7 |
| 6 interface Link<T> extends Iterable<T> default LinkFactory<T> { | 8 interface Link<T> extends Iterable<T> default LinkFactory<T> { |
| 7 Link(T head, [Link<T> tail]); | 9 // does not match constructor for LinkFactory |
| 10 Link(T head, [Link<T> tail]); /// static type error |
| 8 Link<T> prepend(T element); | 11 Link<T> prepend(T element); |
| 9 } | 12 } |
| 10 | 13 |
| 11 interface EmptyLink<T> extends Link<T> default LinkTail<T> { | 14 interface EmptyLink<T> extends Link<T> default LinkTail<T> { |
| 12 const EmptyLink(); | 15 const EmptyLink(); |
| 13 } | 16 } |
| 14 | 17 |
| 15 class LinkFactory<T> { | 18 class LinkFactory<T> { |
| 16 factory Link(head, [Link tail]) { | 19 factory Link(head, [Link tail]) { |
| 17 } | 20 } |
| 18 } | 21 } |
| 19 | 22 |
| 20 class AbstractLink<T> implements Link<T> { | 23 // Does not implement all of Iterable |
| 24 class AbstractLink<T> implements Link<T> { /// static type error |
| 21 const AbstractLink(); | 25 const AbstractLink(); |
| 22 Link<T> prepend(T element) { | 26 Link<T> prepend(T element) { |
| 23 return new Link<T>(element, this); | 27 return new Link<T>(element, this); |
| 24 } | 28 } |
| 25 } | 29 } |
| 26 | 30 |
| 27 class LinkTail<T> extends AbstractLink<T> implements EmptyLink<T> { | 31 // Does not implement all of Iterable |
| 32 class LinkTail<T> extends AbstractLink<T> /// static type error |
| 33 implements EmptyLink<T> { |
| 28 const LinkTail(); | 34 const LinkTail(); |
| 29 } | 35 } |
| 30 | 36 |
| 31 class LinkEntry<T> extends AbstractLink<T> { | 37 // Does not implement all of Iterable |
| 38 class LinkEntry<T> extends AbstractLink<T> { /// static type error |
| 32 LinkEntry(T head, Link<T> realTail); | 39 LinkEntry(T head, Link<T> realTail); |
| 33 } | 40 } |
| 34 | 41 |
| 35 class Fisk { | 42 class Fisk { |
| 36 Link<String> nodes = const EmptyLink(); | 43 // instantiation of abstract class |
| 44 Link<String> nodes = const EmptyLink(); /// static type error |
| 37 } | 45 } |
| 38 | 46 |
| 39 main() { | 47 main() { |
| 40 new Fisk(); | 48 new Fisk(); |
| 41 new EmptyLink<String>().prepend('hest'); | 49 // instantiation of abstract class |
| 42 const EmptyLink<String>().prepend('fisk'); | 50 new EmptyLink<String>().prepend('hest'); /// static type error |
| 51 // instantiation of abstract class |
| 52 const EmptyLink<String>().prepend('fisk'); /// static type error |
| 43 } | 53 } |
| 44 | 54 |
| OLD | NEW |