Closed
Description
Filing under "please lets fix this in Dart 2.1+".
Migrating internal code to Dart2, I hit the following fun error case:
class Link {
static Link parse(Map<String, dynamic> linkData) {
var userIds = linkData['userIds'].map((id) => int.parse(id));
return new Link(userIds: userIds.toList());
}
final List<int> userIds;
const Link({this.userIds});
}
... throws ...
type 'List<dynamic>' is not a subtype of type 'List<int>'
Huh? Shouldn't this work:
.map((id) => int.parse(id));
It turns out, no! .map
is a dcall, because linkData['userIds']
is dynamic
. DOH!
Would --no-implicit-dynamic
fix this? It seems like its an "explicit dynamic" (the map is typed of having values of type dynamic
explicitly). It sounds like we'd need something strong_er_, i.e .--no-dynamic-calls
.
/cc @leafpetersen @lrhn