Fixes #1191. Generic instantiation of 'call' method is now allowed
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A01_t02.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A01_t02.dart
index d92001c..825b5e0 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A01_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A01_t02.dart
@@ -27,5 +27,5 @@
var funcValue = foo;
X Function<X>(X) f = funcValue.call;
Expect.equals(42, f(42));
- Expect.equals(3.14, f(3.14));
+ Expect.equals(3.14, f<double>(3.14));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t01.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t01.dart
index 26ed9fa..15dbd50 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t01.dart
@@ -14,26 +14,28 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
T foo1<T>(T value) => value;
main() {
var funcValue1 = foo1;
- int Function(int) f1 = funcValue1.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ var f1 = funcValue1.call;
+ Expect.equals(42, f1(42));
+ Expect.equals(42, f1<int>(42));
+ Expect.equals(42, funcValue1.call<int>(42));
T foo2<T>(T value) => value;
var funcValue2 = foo2;
- int Function(int) f2 = funcValue2.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ var f2 = funcValue2.call;
+ Expect.equals(42, f2(42));
+ Expect.equals(42, f2<int>(42));
+ Expect.equals(42, funcValue2.call<int>(42));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t02.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t02.dart
index 975c8d1..22d55e2 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t02.dart
@@ -14,17 +14,19 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
main() {
var funcValue = <T>(T t) => t;
- int Function(int) f = funcValue.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T t) f = funcValue.call;
+ Expect.equals(42, f<int>(42));
+ Expect.equals(3.14, f<double>(3.14));
+ Expect.equals("Lily was here", funcValue.call<String>("Lily was here"));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t03.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t03.dart
index 73f660d..4b702dd 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t03.dart
@@ -14,13 +14,15 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
class C {
static T staticMethod<T>(T value) => value;
T instanceMethod<T>(T value) => value;
@@ -28,15 +30,15 @@
main() {
var funcValue1 = C.staticMethod;
- int Function(int) f1 = funcValue1.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T) f1 = funcValue1.call;
+ Expect.equals(42, f1<int>(42));
+ Expect.equals(3.14, f1<double>(3.14));
+ Expect.equals("Lily was here", funcValue1.call<String>("Lily was here"));
C c = new C();
var funcValue2 = c.instanceMethod;
- int Function(int) f2 = funcValue2.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T) f2 = funcValue2.call;
+ Expect.equals(42, f2<int>(42));
+ Expect.equals(3.14, f2<double>(3.14));
+ Expect.equals("Lily was here", funcValue2.call<String>("Lily was here"));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t04.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t04.dart
index 357ea81..d946d9c 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t04.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t04.dart
@@ -14,28 +14,26 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
-typedef int Foo(int i);
+import "../../Utils/expect.dart";
+
+typedef T Foo<T>(T t);
T foo1<T>(T value) => value;
main() {
var funcValue1 = foo1;
- Foo f1 = funcValue1.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ Foo<int> f1 = funcValue1.call<int>;
+ Expect.equals(42, f1(42));
T foo2<T>(T value) => value;
var funcValue2 = foo2;
- Foo f2 = funcValue2.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ Foo<double> f2 = funcValue2.call<double>;
+ Expect.equals(3.14, f2(3.14));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t05.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t05.dart
index ead23bd..6daafdc 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A02_t05.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A02_t05.dart
@@ -14,28 +14,26 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
typedef int Foo<T>(int i);
T foo1<T>(T value) => value;
main() {
var funcValue1 = foo1;
- Foo<int> f1 = funcValue1.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ Foo<int> f1 = funcValue1.call<int>;
+ Expect.equals(42, f1(42));
T foo2<T>(T value) => value;
var funcValue2 = foo2;
- Foo<int> f2 = funcValue2.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ Foo<int> f2 = funcValue2.call<int>;
+ Expect.equals(42, f2(42));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A03_t01.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A03_t01.dart
index 8168182..d238458 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A03_t01.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A03_t01.dart
@@ -14,8 +14,8 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type by ?.
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type by ?.
/// @author sgrekhov@unipro.ru
// SharedOptions=--enable-experiment=constructor-tearoffs
@@ -24,15 +24,15 @@
main() {
var funcValue1 = foo1;
- int Function(int)? f1 = funcValue1?.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T)? f1 = funcValue1?.call;
+// ^^
+// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
+// [cfe] Operand of null-aware operation '?.' has type 'T Function<T>(T)' which excludes null.
T foo2<T>(T value) => value;
var funcValue2 = foo2;
- int Function(int)? f2 = funcValue2?.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T)? f2 = funcValue2?.call;
+// ^^
+// [analyzer] STATIC_WARNING.INVALID_NULL_AWARE_OPERATOR
+// [cfe] Operand of null-aware operation '?.' has type 'T Function<T>(T)' which excludes null.
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A03_t02.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A03_t02.dart
index b99019c..ce30899 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A03_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A03_t02.dart
@@ -14,28 +14,29 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type using super.
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type using super.
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
class A {
T foo<T>(T value) => value;
}
class C extends A {
test() {
- int Function(int) f1 = super.foo.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T) f1 = super.foo.call;
+ Expect.equals(42, f1<int>(42));
+ Expect.equals(3.14, f1<double>(3.14));
+
var funcVal = super.foo;
- int Function(int) f2 = funcVal.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T) f2 = funcVal.call;
+ Expect.equals(42, f2<int>(42));
+ Expect.equals(3.14, f2<double>(3.14));
}
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A03_t03.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A03_t03.dart
index f02ce7c..b334735 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A03_t03.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A03_t03.dart
@@ -14,13 +14,15 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile-time error to tear-off a call
-/// method of a generic function type using super.
+/// @description Checks that it is not an error to tear-off a call method of a
+/// generic function type using super.
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
typedef int Foo(int i);
class A {
@@ -28,13 +30,10 @@
}
class C extends A {
- Foo getCall() => super.foo.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ Foo getCall() => super.foo.call<int>;
}
main() {
C c = new C();
- c.getCall();
+ Expect.equals(42, c.getCall()(42));
}
diff --git a/LanguageFeatures/Constructor-tear-offs/call_method_A04_t02.dart b/LanguageFeatures/Constructor-tear-offs/call_method_A04_t02.dart
index 58aa3e0..d1711b0 100644
--- a/LanguageFeatures/Constructor-tear-offs/call_method_A04_t02.dart
+++ b/LanguageFeatures/Constructor-tear-offs/call_method_A04_t02.dart
@@ -14,22 +14,23 @@
/// (so the tear-off is always generic, even if the context type requires it not
/// to be, which is then guaranteed to introduce a type error).
///
-/// @description Checks that it is a compile error to tear-off a 'call' method
+/// @description Checks that it is not an error to tear-off a 'call' method
/// of a 'call' method of a user defined classes
/// @author sgrekhov@unipro.ru
/// @issue 46902
// SharedOptions=--enable-experiment=constructor-tearoffs
+import "../../Utils/expect.dart";
+
class C {
T call<T>(T t) => t;
}
main() {
C c = new C();
- int Function(int) f1 = c.call;
- int Function(int) f2 = c.call.call;
-// ^^^^
-// [analyzer] unspecified
-// [cfe] unspecified
+ T Function<T>(T) f1 = c.call;
+ T Function<T>(T) f2 = c.call.call;
+ Expect.equals(42, f1<int>(42));
+ Expect.equals(42, f2<int>(42));
}