dart-sdk/tests/language_2/factory_with_type_parameters_test.dart
Aske Simon Christensen f20672e00a Parse name of factory as method name instead of constructor reference.
Report an error when a factory constructor has type parameters.

Report a better error than the old "couldn't find constructor" or
"illegal method name" when the name of a constructor does not match
the name of the enclosing class.

Fixes https://github.com/dart-lang/sdk/issues/31196

Change-Id: Ie46a5b4cbe07ba05ce2936e1f8f9ca2cad0208f7
Reviewed-on: https://dart-review.googlesource.com/57620
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Peter von der Ahé <ahe@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
2018-06-11 09:55:24 +00:00

32 lines
892 B
Dart

// Copyright (c) 2018, 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.
class Foo<T> {
Foo._();
factory Foo
<X> //# 01: compile-time error
<X extends T> //# 02: compile-time error
() => new Bar<T>();
factory Foo
<X> //# 03: compile-time error
<X extends T> //# 04: compile-time error
.far
<X> //# 05: compile-time error
<X extends T> //# 06: compile-time error
<X>.fip //# 07: compile-time error
<X extends T>.fip //# 08: compile-time error
() => new Bar<T>();
}
class Bar<T> extends Foo<T> {
Bar(): super._() {}
}
main() {
new Foo<String>();
new Foo<String>.far();
}