Closed lrhn closed 2 months ago
@lrhn Can these changes be merged?
Well, now it has conflicts! But otherwise yes. Fixing conflicts. ... and done. Someone had made a 4.0.1, so this is now 4.0.2.
Feel free to commit. (I don't have commit rights to the repo.)
Map.of
creates a new map with the same keys, values and type as the original map, when used without type arguments or context type, whereMap.from
creates aMap<dynamic, dynamic>
. (This code failed on an attempt to makeMap.unmodifiable
be more strictly typed, likeMap.of
instead ofMap.from
, showing that an intermediate map had typeMap<dynamic, dynamic>
unnecessarily).Same for using
List.of
instead ofList.from
.The new code should be (microscopically) more efficient and type safe, and is forwards-compatible with a stronger type on
Map.unmodifiable
.(The code can be optimized more. For example
List.of(list1)..addAll(list2)
can be justlist1 + list2
or[...list1, ...list2]
, both of which may know the total number of elements when doing the initial list allocation. This is a minimal change to allow the type changes for.unmodifiable
to get past this very initial blocker in internal tests.)