Closed
Description
Dart SDK version: 2.14.0-3.0.dev (dev) (Tue Apr 13 22:57:19 2021 -0700) on "windows_x64"
Please try to run the following code:
typedef void TEST<T extends void Function<TT>()>();
void testme<T extends void Function<TT>()>() { print(T); }
main() {
TEST t = testme;
dynamic t1 = t;
dynamic t2 = testme;
print(testme is TEST);
print(t is TEST);
print(t1 is TEST);
print(t2 is TEST);
t = t1;
t = t2;
}
It's expected that a runtime type of t
, t1
and t2
variables is the same (they points to the same Function
object). However, this is not so - dart sample output is:
$> dart --enable-experiment=nonfunction-type-aliases,generic-metadata test.dart
false
true
true
false
Unhandled exception:
type '<T extends <X1>() => void>() => void' is not a subtype of type '() => void'
#0 main (file:///D:/DART/sdk/tests/co19/src/LanguageFeatures/Generic-functions-as-type-args/test.dart:16:3)
#1 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:283:19)
#2 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
Analyzer silently passes with the example above.
See also Issue 45313, Issue 45322.
Metadata
Metadata
Assignees
Labels
No labels