Consider the following code
dynamic forgetType(dynamic d) => d;
typedef T0 = void Function();
typedef T1 = void Function<X>();
void t0Instance() {}
void t1Instance<X>() {}
class ArgumentsBindingTest<X> {
ArgumentsBindingTest(X t1) {}
}
main() {
T0 t0 = t0Instance;
T1 t1 = t1Instance;
new ArgumentsBindingTest<T0>(forgetType(t0)); // works
new ArgumentsBindingTest<T1>(forgetType(t1)); // error
}
This code produces
error: generic function type '<X>() => void' not allowed as type argument of type 'ArgumentsBindingTest<<X>() => void>'
#0 _startIsolate.<anonymous closure> (dart:isolate/runtime/libisolate_patch.dart:279:19)
#1 _RawReceivePortImpl._handleMessage (dart:isolate/runtime/libisolate_patch.dart:165:12)
Why function type can be used as a type parameter, but generic function type cannot?
Dart VM version: 2.0.0-dev.63.0 (Fri Jun 15 00:42:43 2018 +0200) on "windows_x64"
Consider the following code
This code produces
Why function type can be used as a type parameter, but generic function type cannot?
Dart VM version: 2.0.0-dev.63.0 (Fri Jun 15 00:42:43 2018 +0200) on "windows_x64"