Description
Dart VM version: 2.9.0-3.0.dev (dev) (Thu Apr 23 09:59:01 2020 +0200) on "windows_x64"
The following source code causes a compile error in analyzer and runtime error in dart:
typedef F<X> = void Function<Y extends X>();
F<X> toF<X>(X x) => throw "It's runtime!";
Type typeOf<X>() => X;
typedef G<X extends num> = void Function();
main() {
G? source;
var fsource = toF(source);
F<G<num>?>? target1 = fsource;
F<G<Object>?>? target2 = fsource;
}
It seems like both tools should behave in a similar way here.
Sample output is:
$> dartanalyzer --enable-experiment=non-nullable test.dart
Analyzing test.dart...
error - 'Object' doesn't extend 'num'. - test.dart:12:7 - type_argument_not_matching_bounds
hint - The value of the local variable 'target1' isn't used. - test.dart:11:15 - unused_local_variable
hint - The value of the local variable 'target2' isn't used. - test.dart:12:18 - unused_local_variable
1 error and 2 hints found.$> dart --enable-experiment=non-nullable test.dart
Unhandled exception:
It's runtime!
#0 toF (file:///D:/DART/sdk/tests/co19/src/LanguageFeatures/Simple-bounds/static/test.dart:3:21)
#1 main (file:///D:/DART/sdk/tests/co19/src/LanguageFeatures/Simple-bounds/static/test.dart:10:17)
#2 _startIsolate. (dart:isolate-patch/isolate_patch.dart:301:19)
#3 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)