#1087. More function tear-offs tests added
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t03.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t03.dart
index d01ac27..514f7a6 100644
--- a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A01_t03.dart
@@ -43,4 +43,9 @@
// ^
// [analyzer] unspecified
// [cfe] unspecified
+
+ idInt<double>(3.14);
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t01.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t01.dart
new file mode 100644
index 0000000..ba4ce31
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t01.dart
@@ -0,0 +1,40 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of generic instance method
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ var x;
+ C() {
+ x = instanceMethod<int>;
+ }
+ T instanceMethod<T>(T t) => t;
+}
+
+main() {
+ C c = new C();
+ Expect.equals(42, c.x(42));
+ dynamic d1 = -42;
+ Expect.isTrue(c.x(d1) is int);
+ Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic
+ dynamic d2 = 3.14;
+ Expect.throws(() {c.x(d2);});
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t02.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t02.dart
new file mode 100644
index 0000000..5415798
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t02.dart
@@ -0,0 +1,40 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of generic instance method
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class C {
+ var x;
+ C() {
+ x = instanceMethod<int>;
+ }
+ T instanceMethod<T>(T t) => t;
+}
+
+main() {
+ C c = new C();
+ c.x(3.14);
+// ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ c.x<double>(42);
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t03.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t03.dart
new file mode 100644
index 0000000..65dd46f
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t03.dart
@@ -0,0 +1,40 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of generic instance method including 'this'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class C {
+ var x;
+ C() {
+ x = this.instanceMethod<int>;
+ }
+ T instanceMethod<T>(T t) => t;
+}
+
+main() {
+ C c = new C();
+ Expect.equals(42, c.x(42));
+ dynamic d1 = -42;
+ Expect.isTrue(c.x(d1) is int);
+ Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic
+ dynamic d2 = 3.14;
+ Expect.throws(() {c.x(d2);});
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t04.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t04.dart
new file mode 100644
index 0000000..a2e2bf8
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t04.dart
@@ -0,0 +1,40 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of generic instance method including 'this'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class C {
+ var x;
+ C() {
+ x = this.instanceMethod<int>;
+ }
+ T instanceMethod<T>(T t) => t;
+}
+
+main() {
+ C c = new C();
+ c.x(3.14);
+// ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ c.x<double>(42);
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t05.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t05.dart
new file mode 100644
index 0000000..e6cdbdd
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t05.dart
@@ -0,0 +1,43 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class A {
+ T instanceMethod<T>(T t) => t;
+}
+
+class C extends A {
+ var x;
+ C() {
+ x = instanceMethod<int>;
+ }
+}
+
+main() {
+ C c = new C();
+ Expect.equals(42, c.x(42));
+ dynamic d1 = -42;
+ Expect.isTrue(c.x(d1) is int);
+ Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic
+ dynamic d2 = 3.14;
+ Expect.throws(() {c.x(d2);});
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t06.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t06.dart
new file mode 100644
index 0000000..a647f51
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t06.dart
@@ -0,0 +1,43 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class A {
+ T instanceMethod<T>(T t) => t;
+}
+
+class C extends A {
+ var x;
+ C() {
+ x = instanceMethod<int>;
+ }
+}
+
+main() {
+ C c = new C();
+ c.x(3.14);
+// ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ c.x<double>(42);
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t07.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t07.dart
new file mode 100644
index 0000000..eb3fec6
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t07.dart
@@ -0,0 +1,44 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method including
+/// 'this'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class A {
+ T instanceMethod<T>(T t) => t;
+}
+
+class C extends A {
+ var x;
+ C() {
+ x = this.instanceMethod<int>;
+ }
+}
+
+main() {
+ C c = new C();
+ Expect.equals(42, c.x(42));
+ dynamic d1 = -42;
+ Expect.isTrue(c.x(d1) is int);
+ Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic
+ dynamic d2 = 3.14;
+ Expect.throws(() {c.x(d2);});
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t08.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t08.dart
new file mode 100644
index 0000000..0b58889
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t08.dart
@@ -0,0 +1,44 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method including
+/// 'this'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class A {
+ T instanceMethod<T>(T t) => t;
+}
+
+class C extends A {
+ var x;
+ C() {
+ x = this.instanceMethod<int>;
+ }
+}
+
+main() {
+ C c = new C();
+ c.x(3.14);
+// ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ c.x<double>(42);
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t09.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t09.dart
new file mode 100644
index 0000000..1bb3a1c
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t09.dart
@@ -0,0 +1,44 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method including
+/// 'super'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class A {
+ T instanceMethod<T>(T t) => t;
+}
+
+class C extends A {
+ var x;
+ C() {
+ x = super.instanceMethod<int>;
+ }
+}
+
+main() {
+ C c = new C();
+ Expect.equals(42, c.x(42));
+ dynamic d1 = -42;
+ Expect.isTrue(c.x(d1) is int);
+ Expect.isFalse(c.x(d1) is double); // to check that returned type is not dynamic
+ dynamic d2 = 3.14;
+ Expect.throws(() {c.x(d2);});
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t10.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t10.dart
new file mode 100644
index 0000000..92a490a
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t10.dart
@@ -0,0 +1,44 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method including
+/// 'super'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+class A {
+ T instanceMethod<T>(T t) => t;
+}
+
+class C extends A {
+ var x;
+ C() {
+ x = super.instanceMethod<int>;
+ }
+}
+
+main() {
+ C c = new C();
+ c.x(3.14);
+// ^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+ c.x<double>(42);
+// ^^^^^^^^
+// [analyzer] unspecified
+// [cfe] unspecified
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t11.dart b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t11.dart
new file mode 100644
index 0000000..abaee25
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/function_tearoffs_A02_t11.dart
@@ -0,0 +1,52 @@
+// 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 These grammar changes allows type parameters without following
+/// parenthesized arguments in places where we previously did not allow them.
+/// For example, this means that <typeArguments> becomes a selector by itself,
+/// not just followed by arguments.
+//
+// It applies to instance methods as well as local, static and top-level
+// function declarations. For instance methods, it applies to references of the
+// form
+//
+// instanceMethod<int> (with implicit this),
+// object.instanceMethod<int> (including this) and super.instanceMethod<int>.
+///
+/// @description Checks tear-off of inherited generic instance method including
+/// 'super'
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+class A {
+ String log = "";
+ T instanceMethod<T>(T t) {
+ log = "A";
+ return t;
+ }
+}
+
+class C extends A {
+ var x1;
+ var x2;
+ C() {
+ x1 = super.instanceMethod<int>;
+ x2 = this.instanceMethod<int>;
+ }
+ T instanceMethod<T>(T t) {
+ log = "C";
+ return t;
+ }
+}
+
+main() {
+ C c = new C();
+ Expect.equals(42, c.x1(42));
+ Expect.equals("A", c.log);
+ Expect.equals(-42, c.x2(-42));
+ Expect.equals("C", c.log);
+}
diff --git a/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01.dart b/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01.dart
new file mode 100644
index 0000000..faa6f89
--- /dev/null
+++ b/LanguageFeatures/Constructor-tear-offs/type_literal_A01_t01.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 We will introduce syntax allowing you to explicitly instantiate a
+/// function tear-off and a type literal for a generic class. The former for
+/// consistency with constructor tear-offs, the latter to introduce in-line
+/// types without needing a typedef, like we did for function types. And we do
+/// both now because they share the same grammar productions.
+///
+/// Example:
+///
+/// T id<T>(T value) => value;
+/// var idInt = id<int>; // Explicitly instantiated tear-off, saves on writing function types.
+/// and
+/// Type intList = List<int>; // In-line instantiated type literal.
+///
+/// @description Checks example from the Spec.
+/// @author sgrekhov@unipro.ru
+
+// SharedOptions=--enable-experiment=constructor-tearoffs
+
+import "../../Utils/expect.dart";
+
+main() {
+ Type intList = List<int>;
+ List<int> list1 = new List<int>.empty();
+ Expect.isTrue(list1.runtimeType == intList);
+ List<double> list2 = new List<double>.empty();
+ Expect.isFalse(list2.runtimeType == intList);
+ List<num> list3 = new List<num>.empty();
+ Expect.isFalse(list3.runtimeType == intList);
+}