Make cast do the same things as retype.
Deprecate `retype` and forward it to `cast`. Change-Id: Ie17ffdd1eef0d3f19582bf638c5349927c7b5ebd Reviewed-on: https://dart-review.googlesource.com/53802 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Leaf Petersen <leafp@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
b347839ee6
commit
862a894de6
@@ -21,12 +21,10 @@ class DebugMap<K, V> implements Map<K, V> {
|
||||
putIfAbsentCallback = value;
|
||||
}
|
||||
|
||||
Map<RK, RV> cast<RK, RV>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<RK, RV> ? self : this.retype<RK, RV>();
|
||||
}
|
||||
Map<RK, RV> cast<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);
|
||||
|
||||
Map<RK, RV> retype<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<RK, RV> retype<RK, RV>() => cast<RK, RV>();
|
||||
|
||||
bool containsValue(Object value) {
|
||||
return sourceMap.containsValue(value);
|
||||
@@ -109,12 +107,10 @@ class DebugIterable<E> implements Iterable<E> {
|
||||
|
||||
Iterator<E> get iterator => iterable.iterator;
|
||||
|
||||
Iterable<R> cast<R>() {
|
||||
Iterable<Object> self = this;
|
||||
return self is Iterable<R> ? self : this.retype<R>();
|
||||
}
|
||||
Iterable<R> cast<R>() => Iterable.castFrom<E, R>(this);
|
||||
|
||||
Iterable<R> retype<R>() => Iterable.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Iterable<R> retype<R>() => cast<R>();
|
||||
|
||||
Iterable<T> map<T>(T f(E element)) => iterable.map(f);
|
||||
|
||||
@@ -193,12 +189,10 @@ class DebugList<E> extends DebugIterable<E> implements List<E> {
|
||||
|
||||
List<E> get list => iterable;
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : this.retype<R>();
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<E, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
List<E> operator +(List<E> other) => list + other;
|
||||
|
||||
@@ -302,12 +296,10 @@ class DebugSet<E> extends DebugIterable<E> implements Set<E> {
|
||||
|
||||
Set<E> get set => iterable;
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : this.retype<R>();
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
bool contains(Object value) => set.contains(value);
|
||||
|
||||
|
||||
@@ -68,12 +68,10 @@ class ExpensiveMap<K, V> extends MapBase<K, V> {
|
||||
}
|
||||
}
|
||||
|
||||
Map<KR, VR> cast<KR, VR>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<KR, VR> ? self : Map.castFrom<K, V, KR, VR>(this);
|
||||
}
|
||||
Map<KR, VR> cast<KR, VR>() => Map.castFrom<K, V, KR, VR>(this);
|
||||
|
||||
Map<KR, VR> retype<KR, VR>() => Map.castFrom<K, V, KR, VR>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<KR, VR> retype<KR, VR>() => cast<KR, VR>();
|
||||
|
||||
Iterable<MapEntry<K, V>> get entries => _maps[0].entries;
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ class TrackMap<K, V> implements Map<K, V> {
|
||||
|
||||
Map<KR, VR> cast<KR, VR>() => _map.cast<KR, VR>();
|
||||
|
||||
Map<KR, VR> retype<KR, VR>() => _map.retype<KR, VR>();
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<KR, VR> retype<KR, VR>() => cast<KR, VR>();
|
||||
|
||||
Iterable<MapEntry<K, V>> get entries => _map.entries;
|
||||
|
||||
|
||||
@@ -9,12 +9,10 @@ import 'dart:collection' show IterableBase;
|
||||
class ImmutableEmptySet<E> extends IterableBase<E> implements Set<E> {
|
||||
const ImmutableEmptySet();
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : this.retype<R>();
|
||||
}
|
||||
Set<R> cast<R>() => new ImmutableEmptySet<R>();
|
||||
|
||||
Set<R> retype<R>() => new ImmutableEmptySet<R>();
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
get iterator => const _EmptySetIterator();
|
||||
int get length => 0;
|
||||
|
||||
@@ -29,7 +29,10 @@ class Setlet<E> extends SetBase<E> {
|
||||
|
||||
static Set<R> _newSet<R>() => new Setlet<R>();
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this, newSet: _newSet);
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newSet);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
Iterator<E> get iterator {
|
||||
if (_extra == null) {
|
||||
|
||||
@@ -66,12 +66,10 @@ class JSArray<E> implements List<E>, JSIndexable<E> {
|
||||
}
|
||||
}
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<E, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<E, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void add(E value) {
|
||||
checkGrowable('add');
|
||||
|
||||
@@ -460,12 +460,10 @@ class _CompactLinkedHashSet<E> extends _HashFieldBase
|
||||
|
||||
static Set<R> _newEmpty<R>() => new _CompactLinkedHashSet<R>();
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : Set.castFrom<E, R>(this, newSet: _newEmpty);
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newEmpty);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this, newSet: _newEmpty);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
int get length => _usedData - _deletedKeys;
|
||||
|
||||
@@ -623,12 +621,10 @@ class _CompactLinkedIdentityHashSet<E> extends _CompactLinkedHashSet<E>
|
||||
|
||||
static Set<R> _newEmpty<R>() => new _CompactLinkedIdentityHashSet<R>();
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : Set.castFrom<E, R>(this, newSet: _newEmpty);
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newEmpty);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this, newSet: _newEmpty);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
}
|
||||
|
||||
class _CompactLinkedCustomHashSet<E> extends _CompactLinkedHashSet<E> {
|
||||
@@ -646,12 +642,10 @@ class _CompactLinkedCustomHashSet<E> extends _CompactLinkedHashSet<E> {
|
||||
_CompactLinkedCustomHashSet(this._equality, this._hasher, validKey)
|
||||
: _validKey = (validKey != null) ? validKey : new _TypeTest<E>().test;
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : Set.castFrom<E, R>(this);
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
Set<E> toSet() =>
|
||||
new _CompactLinkedCustomHashSet<E>(_equality, _hasher, _validKey)
|
||||
|
||||
@@ -13,12 +13,10 @@ class _ImmutableMap<K, V> implements Map<K, V> {
|
||||
const _ImmutableMap._create(_ImmutableList keyValuePairs)
|
||||
: _kvPairs = keyValuePairs;
|
||||
|
||||
Map<K2, V2> cast<K2, V2>() {
|
||||
Map<Object, Object> self = this;
|
||||
return (self is Map<K2, V2>) ? self : this.retype<K2, V2>();
|
||||
}
|
||||
Map<K2, V2> cast<K2, V2>() => Map.castFrom<K, V, K2, V2>(this);
|
||||
|
||||
Map<K2, V2> retype<K2, V2>() => Map.castFrom<K, V, K2, V2>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<K2, V2> retype<K2, V2>() => cast<K2, V2>();
|
||||
|
||||
V operator [](Object key) {
|
||||
// To preserve the key-value order of the map literal, the keys are
|
||||
|
||||
@@ -123,12 +123,10 @@ abstract class _IntListMixin implements List<int> {
|
||||
Iterable<int> followedBy(Iterable<int> other) =>
|
||||
new FollowedByIterable<int>.firstEfficient(this, other);
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<int, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<int, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<int, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void set first(int value) {
|
||||
if (this.length == 0) throw new RangeError.index(0, this);
|
||||
@@ -486,12 +484,10 @@ abstract class _DoubleListMixin implements List<double> {
|
||||
Iterable<double> followedBy(Iterable<double> other) =>
|
||||
new FollowedByIterable<double>.firstEfficient(this, other);
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<double, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<double, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<double, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void set first(double value) {
|
||||
if (this.length == 0) throw new RangeError.index(0, this);
|
||||
@@ -852,12 +848,10 @@ abstract class _Float32x4ListMixin implements List<Float32x4> {
|
||||
Iterable<Float32x4> followedBy(Iterable<Float32x4> other) =>
|
||||
new FollowedByIterable<Float32x4>.firstEfficient(this, other);
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<Float32x4, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<Float32x4, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<Float32x4, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void set first(Float32x4 value) {
|
||||
if (this.length == 0) throw new RangeError.index(0, this);
|
||||
@@ -1222,12 +1216,10 @@ abstract class _Int32x4ListMixin implements List<Int32x4> {
|
||||
Iterable<Int32x4> followedBy(Iterable<Int32x4> other) =>
|
||||
new FollowedByIterable<Int32x4>.firstEfficient(this, other);
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<Int32x4, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<Int32x4, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<Int32x4, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void set first(Int32x4 value) {
|
||||
if (this.length == 0) throw new RangeError.index(0, this);
|
||||
@@ -1591,12 +1583,10 @@ abstract class _Float64x2ListMixin implements List<Float64x2> {
|
||||
Iterable<Float64x2> followedBy(Iterable<Float64x2> other) =>
|
||||
new FollowedByIterable<Float64x2>.firstEfficient(this, other);
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<Float64x2, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<Float64x2, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<Float64x2, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void set first(Float64x2 value) {
|
||||
if (this.length == 0) throw new RangeError.index(0, this);
|
||||
|
||||
@@ -148,7 +148,8 @@ class ObservableList<T> extends AbstractObservable
|
||||
|
||||
List<R> cast<R>() => _internal.cast<R>();
|
||||
|
||||
List<R> retype<R>() => _internal.retype<R>();
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
Iterable<R> whereType<R>() => _internal.whereType<R>();
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ class _HttpSession implements HttpSession {
|
||||
|
||||
Map<K, V> cast<K, V>() => _data.cast<K, V>();
|
||||
|
||||
Map<K, V> retype<K, V>() => _data.retype<K, V>();
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<K, V> retype<K, V>() => cast<K, V>();
|
||||
|
||||
update(key, update(value), {ifAbsent()}) =>
|
||||
_data.update(key, update, ifAbsent: ifAbsent);
|
||||
|
||||
@@ -47,12 +47,10 @@ abstract class ConstantMap<K, V> implements Map<K, V> {
|
||||
|
||||
const ConstantMap._();
|
||||
|
||||
Map<RK, RV> cast<RK, RV>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<RK, RV> ? self : Map.castFrom<K, V, RK, RV>(this);
|
||||
}
|
||||
Map<RK, RV> cast<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);
|
||||
|
||||
Map<RK, RV> retype<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<RK, RV> retype<RK, RV>() => cast<RK, RV>();
|
||||
|
||||
bool get isEmpty => length == 0;
|
||||
|
||||
|
||||
@@ -119,12 +119,10 @@ class JSArray<E> extends Interceptor implements List<E>, JSIndexable {
|
||||
}
|
||||
}
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<E, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<E, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
void add(E value) {
|
||||
checkGrowable('add');
|
||||
|
||||
+11
-28
@@ -932,25 +932,16 @@ abstract class Stream<T> {
|
||||
return future;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt this stream to be a `Stream<R>`.
|
||||
*
|
||||
* If this stream already has the desired type, its returned directly.
|
||||
* Otherwise it is wrapped as a `Stream<R>` which checks at run-time that
|
||||
* each data event emitted by this stream is also an instance of [R].
|
||||
*/
|
||||
Stream<R> cast<R>() {
|
||||
Stream<Object> self = this;
|
||||
return self is Stream<R> ? self : retype<R>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adapt this stream to be a `Stream<R>`.
|
||||
*
|
||||
* This stream is wrapped as a `Stream<R>` which checks at run-time that
|
||||
* each data event emitted by this stream is also an instance of [R].
|
||||
*/
|
||||
Stream<R> retype<R>() => Stream.castFrom<T, R>(this);
|
||||
Stream<R> cast<R>() => Stream.castFrom<T, R>(this);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Stream<R> retype<R>() => cast<R>();
|
||||
|
||||
/**
|
||||
* Collects all elements of this stream in a [List].
|
||||
@@ -2020,15 +2011,6 @@ abstract class StreamTransformer<S, T> {
|
||||
*/
|
||||
Stream<T> bind(Stream<S> stream);
|
||||
|
||||
/**
|
||||
* Provides a `StreamTransformer<RS, RT>` view of this stream transformer.
|
||||
*
|
||||
* If this transformer already has the desired type, or a subtype,
|
||||
* it is returned directly,
|
||||
* otherwise returns the result of `retype<RS, RT>()`.
|
||||
*/
|
||||
StreamTransformer<RS, RT> cast<RS, RT>();
|
||||
|
||||
/**
|
||||
* Provides a `StreamTrasformer<RS, RT>` view of this stream transformer.
|
||||
*
|
||||
@@ -2037,6 +2019,9 @@ abstract class StreamTransformer<S, T> {
|
||||
* and it will check that all data events produced by this transformer
|
||||
* are acually instances of [RT].
|
||||
*/
|
||||
StreamTransformer<RS, RT> cast<RS, RT>();
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
StreamTransformer<RS, RT> retype<RS, RT>();
|
||||
}
|
||||
|
||||
@@ -2048,13 +2033,11 @@ abstract class StreamTransformer<S, T> {
|
||||
abstract class StreamTransformerBase<S, T> implements StreamTransformer<S, T> {
|
||||
const StreamTransformerBase();
|
||||
|
||||
StreamTransformer<RS, RT> cast<RS, RT>() {
|
||||
StreamTransformer<Object, Object> self = this;
|
||||
return self is StreamTransformer<RS, RT> ? self : retype<RS, RT>();
|
||||
}
|
||||
|
||||
StreamTransformer<RS, RT> retype<RS, RT>() =>
|
||||
StreamTransformer<RS, RT> cast<RS, RT>() =>
|
||||
StreamTransformer.castFrom<S, T, RS, RT>(this);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
StreamTransformer<RS, RT> retype<RS, RT>() => cast<RS, RT>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,13 +21,10 @@ class UnmodifiableListView<E> extends UnmodifiableListBase<E> {
|
||||
*/
|
||||
UnmodifiableListView(Iterable<E> source) : _source = source;
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
if (self is List<R>) return self;
|
||||
return new UnmodifiableListView<R>(_source.cast<R>());
|
||||
}
|
||||
List<R> cast<R>() => new UnmodifiableListView(_source.cast<R>());
|
||||
|
||||
List<R> retype<R>() => new UnmodifiableListView(_source.retype<R>());
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
int get length => _source.length;
|
||||
|
||||
|
||||
@@ -14,14 +14,10 @@ abstract class _HashSetBase<E> extends SetBase<E> {
|
||||
|
||||
Set<R> _newSimilarSet<R>();
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R>
|
||||
? self
|
||||
: Set.castFrom<E, R>(this, newSet: _newSimilarSet);
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newSimilarSet);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this, newSet: _newSimilarSet);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
Set<E> difference(Set<Object> other) {
|
||||
Set<E> result = _newSet();
|
||||
|
||||
@@ -15,12 +15,10 @@ abstract class IterableMixin<E> implements Iterable<E> {
|
||||
// - SetMixin
|
||||
// If changing a method here, also change the other copies.
|
||||
|
||||
Iterable<R> cast<R>() {
|
||||
Iterable<Object> self = this;
|
||||
return self is Iterable<R> ? self : Iterable.castFrom<E, R>(this);
|
||||
}
|
||||
Iterable<R> cast<R>() => Iterable.castFrom<E, R>(this);
|
||||
|
||||
Iterable<R> retype<R>() => Iterable.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Iterable<R> retype<R>() => cast<R>();
|
||||
|
||||
Iterable<T> map<T>(T f(E element)) => new MappedIterable<E, T>(this, f);
|
||||
|
||||
|
||||
@@ -329,12 +329,10 @@ abstract class ListMixin<E> implements List<E> {
|
||||
this.length = 0;
|
||||
}
|
||||
|
||||
List<R> cast<R>() {
|
||||
List<Object> self = this;
|
||||
return self is List<R> ? self : List.castFrom<E, R>(this);
|
||||
}
|
||||
List<R> cast<R>() => List.castFrom<E, R>(this);
|
||||
|
||||
List<R> retype<R>() => List.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>() => cast<R>();
|
||||
|
||||
E removeLast() {
|
||||
if (length == 0) {
|
||||
|
||||
@@ -118,12 +118,10 @@ abstract class MapMixin<K, V> implements Map<K, V> {
|
||||
// It should clear the map even if some keys are not equal to themselves.
|
||||
void clear();
|
||||
|
||||
Map<RK, RV> cast<RK, RV>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<RK, RV> ? self : Map.castFrom<K, V, RK, RV>(this);
|
||||
}
|
||||
Map<RK, RV> cast<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);
|
||||
|
||||
Map<RK, RV> retype<RK, RV>() => Map.castFrom<K, V, RK, RV>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<RK, RV> retype<RK, RV>() => cast<RK, RV>();
|
||||
|
||||
void forEach(void action(K key, V value)) {
|
||||
for (K key in keys) {
|
||||
@@ -318,7 +316,8 @@ class MapView<K, V> implements Map<K, V> {
|
||||
|
||||
Map<RK, RV> cast<RK, RV>() => _map.cast<RK, RV>();
|
||||
|
||||
Map<RK, RV> retype<RK, RV>() => _map.retype<RK, RV>();
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<RK, RV> retype<RK, RV>() => cast<RK, RV>();
|
||||
|
||||
V operator [](Object key) => _map[key];
|
||||
void operator []=(K key, V value) {
|
||||
@@ -380,12 +379,9 @@ class UnmodifiableMapView<K, V> extends MapView<K, V>
|
||||
with _UnmodifiableMapMixin<K, V> {
|
||||
UnmodifiableMapView(Map<K, V> map) : super(map);
|
||||
|
||||
Map<RK, RV> cast<RK, RV>() {
|
||||
Map<Object, Object> self = this;
|
||||
if (self is Map<RK, RV>) return self;
|
||||
return new UnmodifiableMapView<RK, RV>(_map.cast<RK, RV>());
|
||||
}
|
||||
Map<RK, RV> cast<RK, RV>() =>
|
||||
new UnmodifiableMapView<RK, RV>(_map.cast<RK, RV>());
|
||||
|
||||
Map<RK, RV> retype<RK, RV>() =>
|
||||
new UnmodifiableMapView<RK, RV>(_map.retype<RK, RV>());
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<RK, RV> retype<RK, RV>() => cast<RK, RV>();
|
||||
}
|
||||
|
||||
@@ -66,9 +66,7 @@ abstract class Queue<E> implements EfficientLengthIterable<E> {
|
||||
new CastQueue<S, T>(source);
|
||||
|
||||
/**
|
||||
* Provides a view of this queue as a queue of [R] instances.
|
||||
*
|
||||
* If this queue is already a `Queue<R>`, it is returned unchanged.
|
||||
* Provides a view of this queue as a queue of [R] instances, if necessary.
|
||||
*
|
||||
* If this queue contains only instances of [R], all read operations
|
||||
* will work correctly. If any operation tries to access an element
|
||||
@@ -81,18 +79,7 @@ abstract class Queue<E> implements EfficientLengthIterable<E> {
|
||||
*/
|
||||
Queue<R> cast<R>();
|
||||
|
||||
/**
|
||||
* Provides a view of this queue as a queue of [R] instances, if necessary.
|
||||
*
|
||||
* If this queue contains only instances of [R], all read operations
|
||||
* will work correctly. If any operation tries to access an element
|
||||
* that is not an instance of [R], the access will throw instead.
|
||||
*
|
||||
* Elements added to the queue (e.g., by using [addFirst] or [addAll])
|
||||
* must be instance of [R] to be valid arguments to the adding function,
|
||||
* and they must be instances of [E] as well to be accepted by
|
||||
* this queue as well.
|
||||
*/
|
||||
@Deprecated("Use cast instead.")
|
||||
Queue<R> retype<R>();
|
||||
|
||||
/**
|
||||
@@ -356,12 +343,10 @@ class DoubleLinkedQueue<E> extends Iterable<E> implements Queue<E> {
|
||||
factory DoubleLinkedQueue.of(Iterable<E> elements) =>
|
||||
new DoubleLinkedQueue<E>()..addAll(elements);
|
||||
|
||||
Queue<R> cast<R>() {
|
||||
Queue<Object> self = this;
|
||||
return self is Queue<R> ? self : Queue.castFrom<E, R>(this);
|
||||
}
|
||||
Queue<R> cast<R>() => Queue.castFrom<E, R>(this);
|
||||
|
||||
Queue<R> retype<R>() => Queue.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Queue<R> retype<R>() => cast<R>();
|
||||
|
||||
int get length => _elementCount;
|
||||
|
||||
@@ -657,12 +642,10 @@ class ListQueue<E> extends ListIterable<E> implements Queue<E> {
|
||||
|
||||
// Iterable interface.
|
||||
|
||||
Queue<R> cast<R>() {
|
||||
Queue<Object> self = this;
|
||||
return self is Queue<R> ? self : this.retype<R>();
|
||||
}
|
||||
Queue<R> cast<R>() => Queue.castFrom<E, R>(this);
|
||||
|
||||
Queue<R> retype<R>() => Queue.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Queue<R> retype<R>() => cast<R>();
|
||||
|
||||
Iterator<E> get iterator => new _ListQueueIterator<E>(this);
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ part of dart.collection;
|
||||
* Implementations of `Set` using this mixin should consider also implementing
|
||||
* `clear` in constant time. The default implementation works by removing every
|
||||
* element.
|
||||
*
|
||||
* The [cast] implementation uses [retype] to do the actual cast, so if
|
||||
* the cast operation wants to pass a custom `newSet` to [Set.castFrom],
|
||||
* it only needs to override [retype].
|
||||
*/
|
||||
abstract class SetMixin<E> implements Set<E> {
|
||||
// This class reimplements all of [IterableMixin].
|
||||
@@ -51,12 +47,10 @@ abstract class SetMixin<E> implements Set<E> {
|
||||
|
||||
bool get isNotEmpty => length != 0;
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : this.retype<R>();
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
Iterable<E> followedBy(Iterable<E> other) =>
|
||||
new FollowedByIterable<E>.firstEfficient(this, other);
|
||||
|
||||
@@ -765,12 +765,10 @@ class SplayTreeSet<E> extends _SplayTree<E, _SplayTreeNode<E>>
|
||||
Set<T> _newSet<T>() =>
|
||||
new SplayTreeSet<T>((T a, T b) => _comparator(a as E, b as E), _validKey);
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
return self is Set<R> ? self : Set.castFrom<E, R>(this, newSet: _newSet);
|
||||
}
|
||||
Set<R> cast<R>() => Set.castFrom<E, R>(this, newSet: _newSet);
|
||||
|
||||
Set<R> retype<R>() => Set.castFrom<E, R>(this, newSet: _newSet);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
int _compare(E e1, E e2) => _comparator(e1, e2);
|
||||
|
||||
|
||||
@@ -56,18 +56,6 @@ abstract class Converter<S, T> extends StreamTransformerBase<S, T> {
|
||||
stream, (EventSink sink) => new _ConverterStreamEventSink(this, sink));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a `Converter<RS, RT>` view of this stream transformer.
|
||||
*
|
||||
* If this transformer already has the desired type, or a subtype,
|
||||
* it is returned directly,
|
||||
* otherwise returns the result of `retype<RS, RT>()`.
|
||||
*/
|
||||
Converter<RS, RT> cast<RS, RT>() {
|
||||
Converter<Object, Object> self = this;
|
||||
return self is Converter<RS, RT> ? self : retype<RS, RT>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a `Converter<RS, RT>` view of this stream transformer.
|
||||
*
|
||||
@@ -76,7 +64,10 @@ abstract class Converter<S, T> extends StreamTransformerBase<S, T> {
|
||||
* and it will check that all conversion output produced by this converter
|
||||
* are acually instances of [RT].
|
||||
*/
|
||||
Converter<RS, RT> retype<RS, RT>() => Converter.castFrom<S, T, RS, RT>(this);
|
||||
Converter<RS, RT> cast<RS, RT>() => Converter.castFrom<S, T, RS, RT>(this);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Converter<RS, RT> retype<RS, RT>() => cast<RS, RT>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -153,20 +153,6 @@ abstract class Iterable<E> {
|
||||
*/
|
||||
Iterator<E> get iterator;
|
||||
|
||||
/**
|
||||
* Makes this iterable useful as an `Iterable<R>`, if necessary.
|
||||
*
|
||||
* Like [retype] except that this iterable is returned as-is
|
||||
* if it is already an `Iterable<R>`.
|
||||
*
|
||||
* It means that `someIterable.cast<Object>().toList()` is not guaranteed
|
||||
* to return precisely a `List<Object>`, but it may return a subtype.
|
||||
*/
|
||||
Iterable<R> cast<R>() {
|
||||
Iterable<Object> self = this;
|
||||
return self is Iterable<R> ? self : Iterable.castFrom<E, R>(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a view of this iterable as an iterable of [R] instances.
|
||||
*
|
||||
@@ -177,7 +163,10 @@ abstract class Iterable<E> {
|
||||
* When the returned iterable creates a new object that depends on
|
||||
* the type [R], e.g., from [toList], it will have exactly the type [R].
|
||||
*/
|
||||
Iterable<R> retype<R>() => Iterable.castFrom<E, R>(this);
|
||||
Iterable<R> cast<R>() => Iterable.castFrom<E, R>(this);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Iterable<R> retype<R>() => cast<R>();
|
||||
|
||||
/**
|
||||
* Returns the lazy concatentation of this iterable and [other].
|
||||
|
||||
+3
-16
@@ -253,22 +253,6 @@ abstract class List<E> implements EfficientLengthIterable<E> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a view of this list as a list of [R] instances, if necessary.
|
||||
*
|
||||
* If this list is already a `List<R>`, it is returned unchanged.
|
||||
*
|
||||
* If this list contains only instances of [R], all read operations
|
||||
* will work correctly. If any operation tries to access an element
|
||||
* that is not an instance of [R], the access will throw instead.
|
||||
*
|
||||
* Elements added to the list (e.g., by using [add] or [addAll])
|
||||
* must be instance of [R] to be valid arguments to the adding function,
|
||||
* and they must be instances of [E] as well to be accepted by
|
||||
* this list as well.
|
||||
*/
|
||||
List<R> cast<R>();
|
||||
|
||||
/**
|
||||
* Returns a view of this list as a list of [R] instances.
|
||||
*
|
||||
@@ -283,6 +267,9 @@ abstract class List<E> implements EfficientLengthIterable<E> {
|
||||
*
|
||||
* Typically implemented as `List.castFrom<E, R>(this)`.
|
||||
*/
|
||||
List<R> cast<R>();
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
List<R> retype<R>();
|
||||
|
||||
/**
|
||||
|
||||
+3
-14
@@ -177,20 +177,6 @@ abstract class Map<K, V> {
|
||||
factory Map.fromEntries(Iterable<MapEntry<K, V>> entries) =>
|
||||
<K, V>{}..addEntries(entries);
|
||||
|
||||
/**
|
||||
* Provides a view of this map as having [RK] keys and [RV] instances,
|
||||
* if necessary.
|
||||
*
|
||||
* If this set contains only keys of type [RK] and values of type [RV],
|
||||
* all read operations will work correctly.
|
||||
* If any operation exposes a non-[RK] key or non-[RV] value,
|
||||
* the operation will throw instead.
|
||||
*
|
||||
* Entries added to the map must be valid for both a `Map<K, V>` and a
|
||||
* `Map<RK, RV>`.
|
||||
*/
|
||||
Map<RK, RV> cast<RK, RV>();
|
||||
|
||||
/**
|
||||
* Provides a view of this map as having [RK] keys and [RV] instances,
|
||||
* if necessary.
|
||||
@@ -205,6 +191,9 @@ abstract class Map<K, V> {
|
||||
* Entries added to the map must be valid for both a `Map<K, V>` and a
|
||||
* `Map<RK, RV>`.
|
||||
*/
|
||||
Map<RK, RV> cast<RK, RV>();
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<RK, RV> retype<RK, RV>();
|
||||
|
||||
/**
|
||||
|
||||
+2
-15
@@ -114,9 +114,7 @@ abstract class Set<E> extends EfficientLengthIterable<E> {
|
||||
new CastSet<S, T>(source, newSet);
|
||||
|
||||
/**
|
||||
* Provides a view of this set as a set of [R] instances, if necessary.
|
||||
*
|
||||
* If this set is already a `Set<R>`, it is returned unchanged.
|
||||
* Provides a view of this set as a set of [R] instances.
|
||||
*
|
||||
* If this set contains only instances of [R], all read operations
|
||||
* will work correctly. If any operation tries to access an element
|
||||
@@ -129,18 +127,7 @@ abstract class Set<E> extends EfficientLengthIterable<E> {
|
||||
*/
|
||||
Set<R> cast<R>();
|
||||
|
||||
/**
|
||||
* Provides a view of this set as a set of [R] instances.
|
||||
*
|
||||
* If this set contains only instances of [R], all read operations
|
||||
* will work correctly. If any operation tries to access an element
|
||||
* that is not an instance of [R], the access will throw instead.
|
||||
*
|
||||
* Elements added to the set (e.g., by using [add] or [addAll])
|
||||
* must be instance of [R] to be valid arguments to the adding function,
|
||||
* and they must be instances of [E] as well to be accepted by
|
||||
* this set as well.
|
||||
*/
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -46414,12 +46414,10 @@ abstract class _AttributeMap extends MapBase<String, String> {
|
||||
});
|
||||
}
|
||||
|
||||
Map<K, V> cast<K, V>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<K, V> ? self : Map.castFrom<String, String, K, V>(this);
|
||||
}
|
||||
Map<K, V> cast<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
|
||||
Map<K, V> retype<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<K, V> retype<K, V>() => cast<K, V>();
|
||||
|
||||
bool containsValue(Object value) {
|
||||
for (var v in this.values) {
|
||||
@@ -46581,12 +46579,10 @@ class _DataAttributeMap extends MapBase<String, String> {
|
||||
});
|
||||
}
|
||||
|
||||
Map<K, V> cast<K, V>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<K, V> ? self : Map.castFrom<String, String, K, V>(this);
|
||||
}
|
||||
Map<K, V> cast<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
|
||||
Map<K, V> retype<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<K, V> retype<K, V>() => cast<K, V>();
|
||||
|
||||
// TODO: Use lazy iterator when it is available on Map.
|
||||
bool containsValue(Object value) => values.any((v) => v == value);
|
||||
|
||||
@@ -18,12 +18,10 @@ class CastStream<S, T> extends Stream<T> {
|
||||
..onData(onData);
|
||||
}
|
||||
|
||||
Stream<R> cast<R>() {
|
||||
Stream<Object> self = this;
|
||||
return self is Stream<R> ? self : this.retype<R>();
|
||||
}
|
||||
Stream<R> cast<R>() => new CastStream<S, R>(_source);
|
||||
|
||||
Stream<R> retype<R>() => new CastStream<S, R>(_source);
|
||||
@Deprecated("Use cast instead.")
|
||||
Stream<R> retype<R>() => cast<R>();
|
||||
}
|
||||
|
||||
class CastStreamSubscription<S, T> implements StreamSubscription<T> {
|
||||
@@ -63,11 +61,12 @@ class CastStreamTransformer<SS, ST, TS, TT>
|
||||
final StreamTransformer<SS, ST> _source;
|
||||
CastStreamTransformer(this._source);
|
||||
|
||||
// cast is inherited from StreamTransformerBase.
|
||||
|
||||
StreamTransformer<RS, RT> retype<RS, RT>() =>
|
||||
StreamTransformer<RS, RT> cast<RS, RT>() =>
|
||||
new CastStreamTransformer<SS, ST, RS, RT>(_source);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
StreamTransformer<RS, RT> retype<RS, RT>() => cast<RS, RT>();
|
||||
|
||||
Stream<TT> bind(Stream<TS> stream) =>
|
||||
_source.bind(stream.cast<SS>()).cast<TT>();
|
||||
}
|
||||
@@ -83,6 +82,9 @@ class CastConverter<SS, ST, TS, TT> extends Converter<TS, TT> {
|
||||
Stream<TT> bind(Stream<TS> stream) =>
|
||||
_source.bind(stream.cast<SS>()).cast<TT>();
|
||||
|
||||
Converter<RS, RT> retype<RS, RT>() =>
|
||||
Converter<RS, RT> cast<RS, RT>() =>
|
||||
new CastConverter<SS, ST, RS, RT>(_source);
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Converter<RS, RT> retype<RS, RT>() => cast<RS, RT>();
|
||||
}
|
||||
|
||||
@@ -188,13 +188,10 @@ class CastSet<S, T> extends _CastIterableBase<S, T> implements Set<T> {
|
||||
|
||||
static Set<R> _defaultEmptySet<R>() => new Set<R>();
|
||||
|
||||
Set<R> cast<R>() {
|
||||
Set<Object> self = this;
|
||||
if (self is Set<R>) return self;
|
||||
return this.retype<R>();
|
||||
}
|
||||
Set<R> cast<R>() => new CastSet<S, R>(_source, _emptySet);
|
||||
|
||||
Set<R> retype<R>() => new CastSet<S, R>(_source, _emptySet);
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
|
||||
bool add(T value) => _source.add(value as S);
|
||||
|
||||
@@ -370,13 +367,10 @@ class CastQueue<S, T> extends _CastIterableBase<S, T>
|
||||
with _CastQueueMixin<S, T> {
|
||||
final Queue<S> _source;
|
||||
CastQueue(this._source);
|
||||
Queue<R> cast<R>() {
|
||||
Queue<Object> self = this;
|
||||
if (self is Queue<R>) return self;
|
||||
return retype<R>();
|
||||
}
|
||||
Queue<R> cast<R>() => new CastQueue<S, R>(_source);
|
||||
|
||||
Queue<R> retype<R>() => new CastQueue<S, R>(_source);
|
||||
@Deprecated("Use cast instead.")
|
||||
Queue<R> retype<R>() => cast<R>();
|
||||
}
|
||||
|
||||
// TODO(lrn): Use when ListQueue implements List.
|
||||
|
||||
@@ -37,7 +37,9 @@ class EfficientTestIterable extends TestIterableBase implements Set<int> {
|
||||
// Avoid warnings because we don't actually implement Set.
|
||||
noSuchMethod(i) => super.noSuchMethod(i);
|
||||
Set<R> cast<R>() => throw "not used by test";
|
||||
Set<R> retype<R>() => throw "not used by test";
|
||||
|
||||
@Deprecated("Use cast instead.")
|
||||
Set<R> retype<R>() => cast<R>();
|
||||
}
|
||||
|
||||
class CallbackIterator implements Iterator<int> {
|
||||
|
||||
@@ -15,12 +15,10 @@ abstract class _AttributeMap extends MapBase<String, String> {
|
||||
});
|
||||
}
|
||||
|
||||
Map<K, V> cast<K, V>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<K, V> ? self : Map.castFrom<String, String, K, V>(this);
|
||||
}
|
||||
Map<K, V> cast<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
|
||||
Map<K, V> retype<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<K, V> retype<K, V>() => cast<K, V>();
|
||||
|
||||
bool containsValue(Object value) {
|
||||
for (var v in this.values) {
|
||||
@@ -182,12 +180,10 @@ class _DataAttributeMap extends MapBase<String, String> {
|
||||
});
|
||||
}
|
||||
|
||||
Map<K, V> cast<K, V>() {
|
||||
Map<Object, Object> self = this;
|
||||
return self is Map<K, V> ? self : Map.castFrom<String, String, K, V>(this);
|
||||
}
|
||||
Map<K, V> cast<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
|
||||
Map<K, V> retype<K, V>() => Map.castFrom<String, String, K, V>(this);
|
||||
@Deprecated("Use cast instead.")
|
||||
Map<K, V> retype<K, V>() => cast<K, V>();
|
||||
|
||||
// TODO: Use lazy iterator when it is available on Map.
|
||||
bool containsValue(Object value) => values.any((v) => v == value);
|
||||
|
||||
Reference in New Issue
Block a user