Open
Description
Dart SDK Version: 2.0.0-dev.55.0
OS: Windows 10
The following code sample assign a parametrized function result to the row variable:
class A<X> {}
X testme<X extends A<X>>() { return null; }
main() {
A a = testme();
}
Dart and dartanalyzer show different results here: test passes without errors or warnings whereas dartanalyzer throws compiler error:
Analyzing test.dart...
error - Couldn't infer type parameter 'X'.
Tried to infer 'A<dynamic>' for 'X' which doesn't work:
Type parameter 'X' declared to extend 'A<A<dynamic>>'.
The type 'A<dynamic>' was inferred from:
Return type declared as 'X'
used where 'A<dynamic>' is required.
Consider passing explicit type argument(s) to the generic.
at test.dart:4:9 - strong_mode_could_not_infer
hint - The value of the local variable 'a' isn't used at test.dart:4:5 - unused_local_variable
1 error and 1 hint found.
I believe both tools should behave in a similar way.
Seems like A a = testme();
is OK and should pass in both cases.