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

Unified Diff: lib/src/unmodifiable_wrappers.dart

Issue 1817463002: Finish @nex3's strong-mode fixes in package:collection and test it in Travis (Closed) Base URL: https://github.com/ochafik/collection.git@master
Patch Set: Created 4 years, 9 months 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
Index: lib/src/unmodifiable_wrappers.dart
diff --git a/lib/src/unmodifiable_wrappers.dart b/lib/src/unmodifiable_wrappers.dart
index 1f784709bea12d94f1fb60a9fc6952f05628026c..86d47ab414940d5b49c33449ef804d70e0def69f 100644
--- a/lib/src/unmodifiable_wrappers.dart
+++ b/lib/src/unmodifiable_wrappers.dart
@@ -25,62 +25,86 @@ class NonGrowableListView<E> extends DelegatingList<E>
/// Mixin class that implements a throwing version of all list operations that
/// change the List's length.
abstract class NonGrowableListMixin<E> implements List<E> {
- static _throw() {
- throw new UnsupportedError(
- "Cannot change the length of a fixed-length list");
- }
+ static final _error = new UnsupportedError(
Leaf 2016/03/18 16:35:40 Another way to tackle this is to define static
ochafik 2016/03/19 01:38:33 Like it, thanks!
+ "Cannot change the length of a fixed-length list");
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void set length(int newLength) => _throw();
+ void set length(int newLength) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- bool add(E value) => _throw();
+ bool add(E value) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void addAll(Iterable<E> iterable) => _throw();
+ void addAll(Iterable<E> iterable) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void insert(int index, E element) => _throw();
+ void insert(int index, E element) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void insertAll(int index, Iterable<E> iterable) => _throw();
+ void insertAll(int index, Iterable<E> iterable) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- bool remove(Object value) => _throw();
+ bool remove(Object value) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- E removeAt(int index) => _throw();
+ E removeAt(int index) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- E removeLast() => _throw();
+ E removeLast() {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void removeWhere(bool test(E element)) => _throw();
+ void removeWhere(bool test(E element)) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void retainWhere(bool test(E element)) => _throw();
+ void retainWhere(bool test(E element)) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void removeRange(int start, int end) => _throw();
+ void removeRange(int start, int end) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void replaceRange(int start, int end, Iterable<E> iterable) => _throw();
+ void replaceRange(int start, int end, Iterable<E> iterable) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the length of the list are disallowed.
- void clear() => _throw();
+ void clear() {
+ throw _error;
+ }
}
/// An unmodifiable set.
@@ -98,67 +122,91 @@ class UnmodifiableSetView<E> extends DelegatingSet<E>
/// Mixin class that implements a throwing version of all set operations that
/// change the Set.
abstract class UnmodifiableSetMixin<E> implements Set<E> {
- _throw() {
- throw new UnsupportedError("Cannot modify an unmodifiable Set");
- }
+ static final _error =
+ new UnsupportedError("Cannot modify an unmodifiable Set");
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- bool add(E value) => _throw();
+ bool add(E value) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- void addAll(Iterable<E> elements) => _throw();
+ void addAll(Iterable<E> elements) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- bool remove(Object value) => _throw();
+ bool remove(Object value) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- void removeAll(Iterable elements) => _throw();
+ void removeAll(Iterable elements) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- void retainAll(Iterable elements) => _throw();
+ void retainAll(Iterable elements) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- void removeWhere(bool test(E element)) => _throw();
+ void removeWhere(bool test(E element)) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- void retainWhere(bool test(E element)) => _throw();
+ void retainWhere(bool test(E element)) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the set are disallowed.
- void clear() => _throw();
+ void clear() {
+ throw _error;
+ }
}
/// Mixin class that implements a throwing version of all map operations that
/// change the Map.
abstract class UnmodifiableMapMixin<K, V> implements Map<K, V> {
- static _throw() {
- throw new UnsupportedError("Cannot modify an unmodifiable Map");
- }
+ static final _error =
+ new UnsupportedError("Cannot modify an unmodifiable Map");
/// Throws an [UnsupportedError];
/// operations that change the map are disallowed.
- void operator []=(K key, V value) => _throw();
+ void operator []=(K key, V value) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the map are disallowed.
- V putIfAbsent(K key, V ifAbsent()) => _throw();
+ V putIfAbsent(K key, V ifAbsent()) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the map are disallowed.
- void addAll(Map<K, V> other) => _throw();
+ void addAll(Map<K, V> other) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the map are disallowed.
- V remove(Object key) => _throw();
+ V remove(Object key) {
+ throw _error;
+ }
/// Throws an [UnsupportedError];
/// operations that change the map are disallowed.
- void clear() => _throw();
+ void clear() {
+ throw _error;
+ }
}
« lib/src/equality.dart ('K') | « lib/src/queue_list.dart ('k') | lib/src/wrappers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698