Open MatrixDev opened 3 years ago
See #field-promotion
@scheglov @stereotype441 I think this may be one of the legacy top level inference warnings we discussed? I don't think the current spec requires this, and the CFE does not issue this warning.
@leafpetersen it is not only a warning. actual type of variable is also wrong (aka dynamic
).
@scheglov @stereotype441 this looks like an example of a place where the analyzer is not yet implementing the top level inference spec. We should discuss whether this can be addressed, or whether we need to revisit the spec here.
Consider following code (which is pretty common in most other languages):
Currently Dart throws warning about inferencing variable
b
type and makes it dynamic:The type of 'b' can't be inferred because it refers to an instance getter, 'a', which has an implicit type.
I think Dart should properly inference type from variable
a
, especially taking to account that exactly the same code will work properly inside the function body: