dart_analsyer - add stricter type inference checks #9401
Labels
area-analyzer
Use area-analyzer for Dart analyzer issues, including the analysis server and code completion.
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
This issue was originally filed by greg.low...@gmail.com
The flag "--type-checks-for-inferred-types" warns about:
var q = new Queue<String>();
q.iAmNotAMethodOnQueue();
But you don't get warnings for:
var q = new Queue<String>();
q = 42;
It would be nice too also warn about this second type of mistake, possibly behind another flag.
If you do really want to mix types in a variable, then label the field as dynamic, and no warnings will be emitted.
dynamic qOrInt = new Queue<String>();
qOrInt = 42
This is how c# mixes static type inference and dynamic types.
The text was updated successfully, but these errors were encountered: