#1087. Added tests that checks factory constructor tear-offs and use of tear-offs in a factory constructors
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t05.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t05.dart
new file mode 100644
index 0000000..f1dbbec
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t05.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion We allow tearing off named constructors.
+///
+/// If [C] denotes a class declaration and [C.name] is the name of a constructor
+/// of that class, we allow you to tear off that constructors as:
+///
+/// C.name, or
+/// C<typeArgs>.name
+///
+/// just as you can currently invoke the constructor as [C.name(args)], or
+/// [C<typeArgs>.name(args)].
+///
+/// @description Checks that tearing off named constructor is allowed for a
+/// non-generic class. Test factory constructor
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+bool called = false;
+
+class C {
+ C() {}
+ factory C.f(int i) {
+ called = true;
+ return new D();
+ }
+}
+
+class D extends C {
+ D() : super();
+}
+
+main() {
+ var v = C.f;
+ C c = v(1);
+ Expect.isTrue(called);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t06.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t06.dart
new file mode 100644
index 0000000..fe911bd
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A01_t06.dart
@@ -0,0 +1,39 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion We allow tearing off named constructors.
+///
+/// If [C] denotes a class declaration and [C.name] is the name of a constructor
+/// of that class, we allow you to tear off that constructors as:
+///
+/// C.name, or
+/// C<typeArgs>.name
+///
+/// just as you can currently invoke the constructor as [C.name(args)], or
+/// [C<typeArgs>.name(args)].
+///
+/// @description Checks that tearing off named constructor is allowed for a
+/// non-generic class. Test factory constructor
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+bool called = false;
+
+class C {
+ C() {}
+ factory C.f(int i) = D.new;
+}
+
+class D extends C {
+ D(int i) : super();
+}
+
+main() {
+ var v = C.f;
+ v(42);
+ Expect.isTrue(called);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t25.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t25.dart
new file mode 100644
index 0000000..23c78fa
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t25.dart
@@ -0,0 +1,35 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion Similarly, [params] is almost exactly the same parameter list
+/// as the constructor [C.name], with the one exception that initializing
+/// formals are represented by normal parameters with the same name and type.
+/// All remaining properties of the parameters are the same as for the
+/// corresponding constructor parameter, including any default values, and
+/// [args] is an argument list passing those parameters to [C.name] directly as
+/// they are received.
+///
+/// @description Checks that [params] is exactly the same parameter list
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ int x;
+ String s;
+ C(this.x, this.s);
+ factory C.f1(int x) = D.new;
+}
+
+class D extends C {
+ D(int x) : super(x, "Lily was here");
+}
+
+main() {
+ C c = new C.f1(42);
+ Expect.equals(42, c.x);
+ Expect.equals("Lily was here", c.s);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t26.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t26.dart
new file mode 100644
index 0000000..fc16ab3
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t26.dart
@@ -0,0 +1,34 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion Similarly, [params] is almost exactly the same parameter list
+/// as the constructor [C.name], with the one exception that initializing
+/// formals are represented by normal parameters with the same name and type.
+/// All remaining properties of the parameters are the same as for the
+/// corresponding constructor parameter, including any default values, and
+/// [args] is an argument list passing those parameters to [C.name] directly as
+/// they are received.
+///
+/// @description Checks that [params] is exactly the same parameter list
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class C {
+ int x;
+ String s;
+ C(this.x, this.s);
+ factory C.f1(int x) = D.new;
+// ^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
+
+class D extends C {
+ D() : super(42, "Lily was here");
+}
+
+main() {
+ new C.f1(42);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t27.dart b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t27.dart
new file mode 100644
index 0000000..041763f
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/named_constructor_A04_t27.dart
@@ -0,0 +1,37 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion Similarly, [params] is almost exactly the same parameter list
+/// as the constructor [C.name], with the one exception that initializing
+/// formals are represented by normal parameters with the same name and type.
+/// All remaining properties of the parameters are the same as for the
+/// corresponding constructor parameter, including any default values, and
+/// [args] is an argument list passing those parameters to [C.name] directly as
+/// they are received.
+///
+/// @description Checks that [params] is exactly the same parameter list
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class D extends C {
+ D() : super(42, "Lily was here");
+}
+
+var Dnew = D.new;
+
+class C {
+ int x;
+ String s;
+ C(this.x, this.s);
+ factory C.f1(int x) = Dnew;
+// ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
+
+
+main() {
+ new C.f1(42);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t01.dart b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t01.dart
new file mode 100644
index 0000000..8584bee
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t01.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion If [C] denotes a class, an expression of [C] by itself already
+/// has a meaning, it evaluates to a [Type] object representing the class, so it
+/// cannot also denote the unnamed constructor.
+///
+/// @description Checks that unnamed constructor tear off can be used in a
+/// factory constructor
+///
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
+class C {
+ C();
+ factory C.f1() = C.new;
+ factory C.f2() = D;
+ factory C.f3() = D.new;
+}
+
+class D extends C {
+ D() : super.new();
+}
+
+main() {
+ Expect.isFalse(C.f1() is D);
+ Expect.isTrue(C.f2() is D);
+ Expect.isTrue(C.f3() is D);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t02.dart b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t02.dart
new file mode 100644
index 0000000..8cce1ae
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t02.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion If [C] denotes a class, an expression of [C] by itself already
+/// has a meaning, it evaluates to a [Type] object representing the class, so it
+/// cannot also denote the unnamed constructor.
+///
+/// @description Checks that unnamed constructor tear off can be used in a
+/// factory constructor
+///
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
+class D extends C {
+ D() : super.new();
+}
+
+var Dnew = D.new;
+
+class C {
+ C();
+ factory C.f1() = C.new;
+ factory C.f2() = Dnew;
+}
+
+main() {
+ Expect.isFalse(C.f1() is D);
+ Expect.isTrue(C.f2() is D);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t03.dart b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t03.dart
new file mode 100644
index 0000000..cd123c0
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t03.dart
@@ -0,0 +1,33 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion If [C] denotes a class, an expression of [C] by itself already
+/// has a meaning, it evaluates to a [Type] object representing the class, so it
+/// cannot also denote the unnamed constructor.
+///
+/// @description Checks that unnamed constructor tear off can be used in a
+/// factory constructor. Test generic classes
+///
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
+class C<T> {
+ T t;
+ C(this.t);
+ factory C.f1(T t) = C<T>.new;
+ factory C.f2(T t) = D<T>;
+ factory C.f3(T t) = D<T>.new;
+}
+
+class D<T> extends C<T> {
+ D(T t) : super.new(t);
+}
+
+main() {
+ Expect.isFalse(C<int>.f1(42) is D<int>);
+ Expect.isTrue(C<int>.f2(42) is D<int>);
+ Expect.isTrue(C<String>.f3("Lily was here") is D<String>);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t04.dart b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t04.dart
new file mode 100644
index 0000000..cd0a531
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/unnamed_constructor_A07_t04.dart
@@ -0,0 +1,32 @@
+// Copyright (c) 2021, 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.
+
+/// @assertion If [C] denotes a class, an expression of [C] by itself already
+/// has a meaning, it evaluates to a [Type] object representing the class, so it
+/// cannot also denote the unnamed constructor.
+///
+/// @description Checks that unnamed constructor tear off can be used in a
+/// factory constructor. Test generic classes
+///
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
+class D<T> extends C<T> {
+ D() : super.new();
+}
+
+var Dnew = D.new;
+
+class C<T> {
+ C(T t);
+ factory C.f1(T t) = C.new;
+ factory C.f2(T t) = Dnew<T>;
+}
+
+main() {
+ Expect.isFalse(C<int>.f1(42) is D<int>);
+ Expect.isTrue(C<String>.f2("Lily was here") is D);
+}