// 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. // Test compile time error for factories with parameterized types. import "dart:collection"; abstract class A { factory A.create() = AFactory.create; // //# 01: compile-time error } class AFactory { // Compile time error: should be AFactory to match abstract class above factory A.create() { // //# 01: compile-time error return null;// //# 01: continued } // //# 01: continued } abstract class Link extends IterableBase { // does not match constructor for LinkFactory factory Link(T head, [Link tail]) = LinkFactory; //# 03: compile-time error Link prepend(T element); } abstract class EmptyLink extends Link { const factory EmptyLink() = LinkTail; } class LinkFactory { factory LinkFactory(head, [Link tail]) {} } // Does not implement all of Iterable class AbstractLink implements Link { /*@compile-error=unspecified*/ const AbstractLink(); Link prepend(T element) { return new Link(element, this); } } // Does not implement all of Iterable class LinkTail extends AbstractLink implements EmptyLink { /*@compile-error=unspecified*/ const LinkTail(); } // Does not implement all of Iterable class LinkEntry extends AbstractLink { /*@compile-error=unspecified*/ LinkEntry(T head, Link realTail); } class Fisk { // instantiation of abstract class Link nodes = const EmptyLink(); /*@compile-error=unspecified*/ } main() { // Equivalent to new Link.create(). var a = new A.create(); // //# none: compile-time error var a = new A.create(); // //# 01: continued new Fisk(); // instantiation of abstract class new EmptyLink().prepend('hest'); //# compile-time error // instantiation of abstract class const EmptyLink().prepend('fisk'); //# compile-time error }