-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
Dart VM version: 2.9.0-17.0.dev (dev) (Thu Jun 18 10:22:39 2020 +0200) on "windows_x64"
The following source code throws unexpected unhandled error when assign generic contravariant function variable:
class X {}
checkme<T extends X>(T? t) {}
typedef Test<T extends X>(T? t);
main() {
Test<X> t2 = checkme;
}
Sample output is:
$> dart --enable-experiment=nonfunction-type-aliases,non-nullable test.dart
Unhandled exception:
type 'X?' is not a subtype of type 'X' of 'T'
#0 _boundsCheckForPartialInstantiation (dart:_internal-patch/internal_patch.dart:146:57)
#1 main (file:///D:/DART/sdk/tests/co19/src/Language/Generics/test.dart)
#2 _startIsolate. (dart:isolate-patch/isolate_patch.dart:301:19)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Please note that dart passes with covariant case, i.e. the following source example passes:
class X {}
T? checkme<T extends X>() {}
typedef T? Test<T extends X>();
main() {
Test<X> t2 = checkme;
}