Index: runtime/lib/mirrors_impl.dart |
diff --git a/runtime/lib/mirrors_impl.dart b/runtime/lib/mirrors_impl.dart |
index 9d8e9cba11ad5341323e7f2462805d4d24d85680..9983abba1410f3288f11f6f7bb3cdefdbc63ff3d 100644 |
--- a/runtime/lib/mirrors_impl.dart |
+++ b/runtime/lib/mirrors_impl.dart |
@@ -7,7 +7,33 @@ |
import "dart:collection"; |
final emptyList = new UnmodifiableListView([]); |
-final emptyMap = new UnmodifiableMapView({}); |
+final emptyMap = new _UnmodifiableMapView({}); |
+ |
+// TODO(14314): Move to dart:collection. |
+class _UnmodifiableMapView<K, V> implements Map<K, V> { |
+ final Map<K, V> _source; |
+ |
+ _UnmodifiableMapView(Map<K, V> source) : _source = source; |
+ |
+ static void _throw() { |
+ throw new UnsupportedError("Cannot modify an unmodifiable Map"); |
+ } |
+ |
+ int get length => _source.length; |
+ bool get isEmpty => _source.isEmpty; |
+ bool get isNotEmpty => _source.isNotEmpty; |
+ V operator [](K key) => _source[key]; |
+ bool containsKey(K key) => _source.containsKey(key); |
+ bool containsValue(V value) => _source.containsValue(value); |
+ void forEach(void f(K key, V value)) => _source.forEach(f); |
+ Iterable<K> get keys => _source.keys; |
+ Iterable<V> get values => _source.values; |
+ void operator []=(K key, V value) => _throw(); |
+ V putIfAbsent(K key, V ifAbsent()) { _throw(); } |
+ void addAll(Map<K, V> other) => _throw(); |
+ V remove(K key) { _throw(); } |
+ void clear() => _throw(); |
+} |
class _InternalMirrorError { |
final String _msg; |
@@ -22,11 +48,11 @@ Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) { |
new_map[key] = value; |
} |
}); |
- return new UnmodifiableMapView(new_map); |
+ return new _UnmodifiableMapView(new_map); |
} |
Map _makeMemberMap(List mirrors) { |
- return new UnmodifiableMapView<Symbol, DeclarationMirror>( |
+ return new _UnmodifiableMapView<Symbol, DeclarationMirror>( |
new Map<Symbol, DeclarationMirror>.fromIterable( |
mirrors, key: (e) => e.simpleName)); |
} |
@@ -614,7 +640,7 @@ class _LocalClassMirror extends _LocalObjectMirror |
} |
}); |
_cachedStaticMembers = |
- new UnmodifiableMapView<Symbol, MethodMirror>(result); |
+ new _UnmodifiableMapView<Symbol, MethodMirror>(result); |
} |
return _cachedStaticMembers; |
} |
@@ -643,7 +669,7 @@ class _LocalClassMirror extends _LocalObjectMirror |
} |
}); |
_cachedInstanceMembers = |
- new UnmodifiableMapView<Symbol, MethodMirror>(result); |
+ new _UnmodifiableMapView<Symbol, MethodMirror>(result); |
} |
return _cachedInstanceMembers; |
} |
@@ -656,7 +682,7 @@ class _LocalClassMirror extends _LocalObjectMirror |
decls.addAll(_constructors); |
typeVariables.forEach((tv) => decls[tv.simpleName] = tv); |
return _declarations = |
- new UnmodifiableMapView<Symbol, DeclarationMirror>(decls); |
+ new _UnmodifiableMapView<Symbol, DeclarationMirror>(decls); |
} |
Map<Symbol, Mirror> _cachedMembers; |
@@ -993,7 +1019,7 @@ class _LocalTypeVariableMirror extends _LocalDeclarationMirror |
String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; |
operator ==(other) { |
- return other is TypeVariableMirror |
+ return other is TypeVariableMirror |
&& simpleName == other.simpleName |
&& owner == other.owner; |
} |
@@ -1162,7 +1188,7 @@ class _LocalLibraryMirror extends _LocalObjectMirror implements LibraryMirror { |
Map<Symbol, DeclarationMirror> get declarations { |
if (_declarations != null) return _declarations; |
return _declarations = |
- new UnmodifiableMapView<Symbol, DeclarationMirror>(_members); |
+ new _UnmodifiableMapView<Symbol, DeclarationMirror>(_members); |
} |
Map<Symbol, Mirror> _cachedMembers; |