Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(883)

Unified Diff: lib/clone.dart

Issue 2477873002: Ensure the substitution map in the CloneVisitor is mutable. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/clone.dart
diff --git a/lib/clone.dart b/lib/clone.dart
index 68277c49fea4d36a60862090051918da9267e3aa..ee315e6bba24827c34d38571cb84341490033e19 100644
--- a/lib/clone.dart
+++ b/lib/clone.dart
@@ -20,7 +20,16 @@ class CloneVisitor extends TreeVisitor {
final Map<TypeParameter, DartType> typeSubstitution;
CloneVisitor({Map<TypeParameter, DartType> typeSubstitution})
- : this.typeSubstitution = typeSubstitution ?? <TypeParameter, DartType>{};
+ : this.typeSubstitution = ensureMutable(typeSubstitution);
+
+ static Map<TypeParameter, DartType> ensureMutable(
+ Map<TypeParameter, DartType> map) {
+ // We need to mutate this map, so make sure we don't use a constant map.
+ if (map == null || map.isEmpty) {
+ return <TypeParameter, DartType>{};
+ }
+ return map;
+ }
TreeNode visitLibrary(Library node) {
throw 'Cloning of libraries is not implemented';
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698