mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Remove most comment syntax casts from sdk.
Eliminates all of the uses of the "/*=" syntax in the sdk libraries that can be trivially converted to implicit downcasts. Bug: Change-Id: I213a5d683f50d0cec0b32482f44330db3b5d618d Reviewed-on: https://dart-review.googlesource.com/21781 Commit-Queue: Leaf Petersen <leafp@google.com> Reviewed-by: Stephen Adams <sra@google.com> Reviewed-by: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
5fb49a27f5
commit
2b5349e259
|
@ -104,7 +104,7 @@ abstract class HashMap<K, V> implements Map<K, V> {
|
|||
factory HashMap.from(Map other) {
|
||||
HashMap<K, V> result = new HashMap<K, V>();
|
||||
other.forEach((k, v) {
|
||||
result[k as Object/*=K*/] = v as Object/*=V*/;
|
||||
result[k] = v;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -129,8 +129,7 @@ abstract class HashSet<E> implements Set<E> {
|
|||
factory HashSet.from(Iterable elements) {
|
||||
HashSet<E> result = new HashSet<E>();
|
||||
for (final e in elements) {
|
||||
E element = e as Object/*=E*/;
|
||||
result.add(element);
|
||||
result.add(e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ abstract class LinkedHashMap<K, V> implements HashMap<K, V> {
|
|||
factory LinkedHashMap.from(Map other) {
|
||||
LinkedHashMap<K, V> result = new LinkedHashMap<K, V>();
|
||||
other.forEach((k, v) {
|
||||
result[k as Object/*=K*/] = v as Object/*=V*/;
|
||||
result[k] = v;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -106,8 +106,7 @@ abstract class LinkedHashSet<E> implements HashSet<E> {
|
|||
factory LinkedHashSet.from(Iterable elements) {
|
||||
LinkedHashSet<E> result = new LinkedHashSet<E>();
|
||||
for (final element in elements) {
|
||||
E e = element as Object/*=E*/;
|
||||
result.add(e);
|
||||
result.add(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -288,6 +288,6 @@ abstract class LinkedListEntry<E extends LinkedListEntry<E>> {
|
|||
* The [entry] must not be in a linked list.
|
||||
*/
|
||||
void insertBefore(E entry) {
|
||||
_list._insertBefore(this as dynamic/*=E*/, entry, updateFirst: true);
|
||||
_list._insertBefore(this, entry, updateFirst: true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,14 +172,12 @@ abstract class _DoubleLinkedQueueEntry<E> extends DoubleLinkedQueueEntry<E> {
|
|||
E get _element => element;
|
||||
|
||||
DoubleLinkedQueueEntry<E> nextEntry() {
|
||||
_DoubleLinkedQueueEntry<E> entry =
|
||||
_nextLink as dynamic/*=DoubleLinkedQueueEntry<E>*/;
|
||||
_DoubleLinkedQueueEntry<E> entry = _nextLink;
|
||||
return entry._asNonSentinelEntry();
|
||||
}
|
||||
|
||||
DoubleLinkedQueueEntry<E> previousEntry() {
|
||||
_DoubleLinkedQueueEntry<E> entry =
|
||||
_previousLink as dynamic/*=DoubleLinkedQueueEntry<E>*/;
|
||||
_DoubleLinkedQueueEntry<E> entry = _previousLink;
|
||||
return entry._asNonSentinelEntry();
|
||||
}
|
||||
}
|
||||
|
@ -271,8 +269,7 @@ class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
|
|||
factory DoubleLinkedQueue.from(Iterable elements) {
|
||||
Queue<E> list = new DoubleLinkedQueue<E>();
|
||||
for (final e in elements) {
|
||||
E element = e as Object/*=E*/;
|
||||
list.addLast(element);
|
||||
list.addLast(e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
@ -536,7 +533,7 @@ class ListQueue<E> extends ListIterable<E> implements Queue<E> {
|
|||
ListQueue<E> queue = new ListQueue<E>(length + 1);
|
||||
assert(queue._table.length > length);
|
||||
for (int i = 0; i < length; i++) {
|
||||
queue._table[i] = elements[i] as Object/*=E*/;
|
||||
queue._table[i] = elements[i];
|
||||
}
|
||||
queue._tail = length;
|
||||
return queue;
|
||||
|
@ -547,7 +544,7 @@ class ListQueue<E> extends ListIterable<E> implements Queue<E> {
|
|||
}
|
||||
ListQueue<E> result = new ListQueue<E>(capacity);
|
||||
for (final element in elements) {
|
||||
result.addLast(element as Object/*=E*/);
|
||||
result.addLast(element);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ class SplayTreeMap<K, V> extends _SplayTree<K, _SplayTreeMapNode<K, V>>
|
|||
[int compare(K key1, K key2), bool isValidKey(potentialKey)]) {
|
||||
SplayTreeMap<K, V> result = new SplayTreeMap<K, V>(compare, isValidKey);
|
||||
other.forEach((k, v) {
|
||||
result[k as Object/*=K*/] = v as Object/*=V*/;
|
||||
result[k] = v;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
@ -353,7 +353,7 @@ class SplayTreeMap<K, V> extends _SplayTree<K, _SplayTreeMapNode<K, V>>
|
|||
V operator [](Object key) {
|
||||
if (!_validKey(key)) return null;
|
||||
if (_root != null) {
|
||||
int comp = _splay(key as dynamic/*=K*/);
|
||||
int comp = _splay(key);
|
||||
if (comp == 0) {
|
||||
return _root.value;
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ class SplayTreeMap<K, V> extends _SplayTree<K, _SplayTreeMapNode<K, V>>
|
|||
|
||||
V remove(Object key) {
|
||||
if (!_validKey(key)) return null;
|
||||
_SplayTreeMapNode<K, V> mapRoot = _remove(key as dynamic/*=K*/);
|
||||
_SplayTreeMapNode<K, V> mapRoot = _remove(key);
|
||||
if (mapRoot != null) return mapRoot.value;
|
||||
return null;
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ class SplayTreeMap<K, V> extends _SplayTree<K, _SplayTreeMapNode<K, V>>
|
|||
}
|
||||
|
||||
bool containsKey(Object key) {
|
||||
return _validKey(key) && _splay(key as dynamic/*=K*/) == 0;
|
||||
return _validKey(key) && _splay(key) == 0;
|
||||
}
|
||||
|
||||
bool containsValue(Object value) {
|
||||
|
@ -654,8 +654,7 @@ class _SplayTreeKeyIterator<K> extends _SplayTreeIterator<K, K> {
|
|||
class _SplayTreeValueIterator<K, V> extends _SplayTreeIterator<K, V> {
|
||||
_SplayTreeValueIterator(SplayTreeMap<K, V> map) : super(map);
|
||||
V _getValue(_SplayTreeNode<K> node) {
|
||||
_SplayTreeMapNode<K, V> mapNode =
|
||||
node as dynamic/*=_SplayTreeMapNode<K, V>*/;
|
||||
_SplayTreeMapNode<K, V> mapNode = node;
|
||||
return mapNode.value;
|
||||
}
|
||||
}
|
||||
|
@ -732,7 +731,7 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
|||
[int compare(E key1, E key2), bool isValidKey(potentialKey)]) {
|
||||
SplayTreeSet<E> result = new SplayTreeSet<E>(compare, isValidKey);
|
||||
for (final element in elements) {
|
||||
E e = element as Object/*=E*/;
|
||||
E e = element;
|
||||
result.add(e);
|
||||
}
|
||||
return result;
|
||||
|
@ -766,7 +765,7 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
|||
|
||||
// From Set.
|
||||
bool contains(Object element) {
|
||||
return _validKey(element) && _splay(element as dynamic/*=E*/) == 0;
|
||||
return _validKey(element) && _splay(element) == 0;
|
||||
}
|
||||
|
||||
bool add(E element) {
|
||||
|
@ -778,7 +777,7 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
|||
|
||||
bool remove(Object object) {
|
||||
if (!_validKey(object)) return false;
|
||||
return _remove(object as dynamic/*=E*/) != null;
|
||||
return _remove(object) != null;
|
||||
}
|
||||
|
||||
void addAll(Iterable<E> elements) {
|
||||
|
@ -792,7 +791,7 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
|||
|
||||
void removeAll(Iterable<Object> elements) {
|
||||
for (Object element in elements) {
|
||||
if (_validKey(element)) _remove(element as dynamic/*=E*/);
|
||||
if (_validKey(element)) _remove(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -806,7 +805,7 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
|||
throw new ConcurrentModificationError(this);
|
||||
}
|
||||
// Equivalent to this.contains(object).
|
||||
if (_validKey(object) && _splay(object as dynamic/*=E*/) == 0) {
|
||||
if (_validKey(object) && _splay(object) == 0) {
|
||||
retainSet.add(_root.key);
|
||||
}
|
||||
}
|
||||
|
@ -820,7 +819,7 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
|||
|
||||
E lookup(Object object) {
|
||||
if (!_validKey(object)) return null;
|
||||
int comp = _splay(object as dynamic/*=E*/);
|
||||
int comp = _splay(object);
|
||||
if (comp != 0) return null;
|
||||
return _root.key;
|
||||
}
|
||||
|
|
|
@ -282,8 +282,11 @@ class JsonEncoder extends Converter<Object, String> {
|
|||
|
||||
Converter<Object, T> fuse<T>(Converter<String, T> other) {
|
||||
if (other is Utf8Encoder) {
|
||||
return new JsonUtf8Encoder(indent, _toEncodable)
|
||||
as dynamic/*=Converter<Object, T>*/;
|
||||
// The instance check guarantees that `T` is (a subtype of) List<int>,
|
||||
// but the static type system doesn't know that, and so we cast.
|
||||
// Cast through dynamic to keep the cast implicit for builds using
|
||||
// unchecked implicit casts.
|
||||
return new JsonUtf8Encoder(indent, _toEncodable) as dynamic;
|
||||
}
|
||||
return super.fuse<T>(other);
|
||||
}
|
||||
|
|
|
@ -726,7 +726,8 @@ class _RandomAccessFile implements RandomAccessFile {
|
|||
throw _exceptionFromResponse(response, "read failed", path);
|
||||
}
|
||||
_resourceInfo.addRead(response[1].length);
|
||||
return response[1] as Object/*=List<int>*/;
|
||||
List<int> result = response[1];
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -740,7 +741,7 @@ class _RandomAccessFile implements RandomAccessFile {
|
|||
throw new FileSystemException("readSync failed", path, result);
|
||||
}
|
||||
_resourceInfo.addRead(result.length);
|
||||
return result as Object/*=List<int>*/;
|
||||
return result;
|
||||
}
|
||||
|
||||
Future<int> readInto(List<int> buffer, [int start = 0, int end]) {
|
||||
|
@ -758,8 +759,8 @@ class _RandomAccessFile implements RandomAccessFile {
|
|||
if (_isErrorResponse(response)) {
|
||||
throw _exceptionFromResponse(response, "readInto failed", path);
|
||||
}
|
||||
var read = response[1];
|
||||
var data = response[2] as Object/*=List<int>*/;
|
||||
int read = response[1];
|
||||
List<int> data = response[2];
|
||||
buffer.setRange(start, start + read, data);
|
||||
_resourceInfo.addRead(read);
|
||||
return read;
|
||||
|
|
|
@ -116,7 +116,7 @@ class _Platform {
|
|||
if (_environmentCache is OSError) {
|
||||
throw _environmentCache;
|
||||
} else {
|
||||
return _environmentCache as Object/*=Map<String, String>*/;
|
||||
return _environmentCache;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ class Point<T extends num> {
|
|||
* _runtime_ _error_ in checked mode.
|
||||
*/
|
||||
Point<T> operator *(num /*T|int*/ factor) {
|
||||
return new Point<T>(
|
||||
(x * factor) as dynamic/*=T*/, (y * factor) as dynamic/*=T*/);
|
||||
return new Point<T>((x * factor), (y * factor));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue