// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. import "dart:collection"; // Test compile time error for factories with parameterized types. abstract class A { A(); A.create(); } abstract class B extends A{} // Compile time error: should be AFactory to match abstract class above class AFactory extends B { factory A.create() { // //# 01: compile-time error return null; // //# 01: continued } // //# 01: continued } abstract class Link extends IterableBase { factory Link(T head, [Link tail]) = LinkEntry; Link prepend(T element); } abstract class EmptyLink extends Link { const factory EmptyLink() = LinkTail; } class AbstractLink implements Link { /*@compile-error=unspecified*/ const AbstractLink(); Link prepend(T element) { print("$element"); if (0 is T) { throw "0 is not a T"; } return new Link(element, this); } } class LinkTail extends AbstractLink implements EmptyLink { /*@compile-error=unspecified*/ const LinkTail(); } class LinkEntry extends AbstractLink { /*@compile-error=unspecified*/ LinkEntry(T head, [Link Tail]); } class Fisk { Link nodes = const EmptyLink(); final int id; Fisk(this.id); toString() => id.toString(); } main() { var a = new AFactory.create(); // //# 01: continued var a = new AFactory.create(); // //# none: compile-time error new Fisk(0).nodes.prepend(new Fisk(1)).prepend(new Fisk(2)); }