Skip to content
This repository has been archived by the owner on Oct 17, 2024. It is now read-only.

Remove references to the deprecated CastError. #118

Merged
merged 1 commit into from
Sep 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/src/delegate/event_sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DelegatingEventSink<T> implements EventSink<T> {
///
/// Unlike [new DelegatingEventSink], this only requires its argument to be an
/// instance of `EventSink`, not `EventSink<T>`. This means that calls to
/// [add] may throw a [CastError] if the argument type doesn't match the
/// [add] may throw a [TypeError] if the argument type doesn't match the
/// reified type of [sink].
@Deprecated(
'Use StreamController<T>(sync: true)..stream.cast<S>().pipe(sink)')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/delegate/future.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DelegatingFuture<T> implements Future<T> {
///
/// This soundly converts a [Future] to a `Future<T>`, regardless of its
/// original generic type, by asserting that its value is an instance of `T`
/// whenever it's provided. If it's not, the future throws a [CastError].
/// whenever it's provided. If it's not, the future throws a [TypeError].
@Deprecated('Use future.then((v) => v as T) instead.')
static Future<T> typed<T>(Future future) =>
future is Future<T> ? future : future.then((v) => v as T);
Expand Down
2 changes: 1 addition & 1 deletion lib/src/delegate/sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DelegatingSink<T> implements Sink<T> {
///
/// Unlike [new DelegatingSink], this only requires its argument to be an
/// instance of `Sink`, not `Sink<T>`. This means that calls to [add] may
/// throw a [CastError] if the argument type doesn't match the reified type of
/// throw a [TypeError] if the argument type doesn't match the reified type of
/// [sink].
@Deprecated(
'Use StreamController<T>(sync: true)..stream.cast<S>().pipe(sink)')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/delegate/stream.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DelegatingStream<T> extends StreamView<T> {
/// This soundly converts a [Stream] to a `Stream<T>`, regardless of its
/// original generic type, by asserting that its events are instances of `T`
/// whenever they're provided. If they're not, the stream throws a
/// [CastError].
/// [TypeError].
@Deprecated('Use stream.cast instead')
static Stream<T> typed<T>(Stream stream) => stream.cast();
}
2 changes: 1 addition & 1 deletion lib/src/delegate/stream_consumer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class DelegatingStreamConsumer<T> implements StreamConsumer<T> {
///
/// Unlike [new StreamConsumer], this only requires its argument to be an
/// instance of `StreamConsumer`, not `StreamConsumer<T>`. This means that
/// calls to [addStream] may throw a [CastError] if the argument type doesn't
/// calls to [addStream] may throw a [TypeError] if the argument type doesn't
/// match the reified type of [consumer].
@Deprecated(
'Use StreamController<T>(sync: true)..stream.cast<S>().pipe(sink)')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/delegate/stream_sink.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class DelegatingStreamSink<T> implements StreamSink<T> {
///
/// Unlike [new StreamSink], this only requires its argument to be an instance
/// of `StreamSink`, not `StreamSink<T>`. This means that calls to [add] may
/// throw a [CastError] if the argument type doesn't match the reified type of
/// throw a [TypeError] if the argument type doesn't match the reified type of
/// [sink].
@Deprecated(
'Use StreamController<T>(sync: true)..stream.cast<S>().pipe(sink)')
Expand Down
2 changes: 1 addition & 1 deletion lib/src/delegate/stream_subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DelegatingStreamSubscription<T> implements StreamSubscription<T> {
/// This soundly converts a [StreamSubscription] to a `StreamSubscription<T>`,
/// regardless of its original generic type, by asserting that its events are
/// instances of `T` whenever they're provided. If they're not, the
/// subscription throws a [CastError].
/// subscription throws a [TypeError].
@Deprecated('Use Stream.cast instead')
// TODO - Remove `TypeSafeStreamSubscription` and tests when removing this.
static StreamSubscription<T> typed<T>(StreamSubscription subscription) =>
Expand Down
2 changes: 1 addition & 1 deletion lib/src/stream_sink_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ abstract class StreamSinkTransformer<S, T> {
/// This soundly converts a [StreamSinkTransformer] to a
/// `StreamSinkTransformer<S, T>`, regardless of its original generic type.
/// This means that calls to [StreamSink.add] on the returned sink may throw a
/// [CastError] if the argument type doesn't match the reified type of the
/// [TypeError] if the argument type doesn't match the reified type of the
/// sink.
@deprecated
// TODO remove TypeSafeStreamSinkTransformer
Expand Down
2 changes: 1 addition & 1 deletion lib/src/typed_stream_transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'dart:async';
/// This soundly converts a [StreamTransformer] to a `StreamTransformer<S, T>`,
/// regardless of its original generic type, by asserting that the events
/// emitted by the transformed stream are instances of `T` whenever they're
/// provided. If they're not, the stream throws a [CastError].
/// provided. If they're not, the stream throws a [TypeError].
@Deprecated('Use Stream.cast after binding a transformer instead')
StreamTransformer<S, T> typedStreamTransformer<S, T>(
StreamTransformer transformer) =>
Expand Down
6 changes: 3 additions & 3 deletions test/typed_wrapper/stream_subscription_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ void main() {
wrapper = TypeSafeStreamSubscription<int>(controller.stream.listen(null));
});

group('throws a CastError for', () {
group('throws a TypeError for', () {
test('onData()', () {
expect(() {
// TODO(nweiz): Use the wrapper declared in setUp when sdk#26226 is
Expand All @@ -90,11 +90,11 @@ void main() {

wrapper.onData(expectAsync1((_) {}, count: 0));
controller.add('foo');
}, throwsZonedCastError);
}, throwsZonedTypeError);
});
});

group("doesn't throw a CastError for", () {
group("doesn't throw a TypeError for", () {
test('onError()', () {
wrapper.onError(expectAsync1((error) {
expect(error, equals('oh no'));
Expand Down
4 changes: 2 additions & 2 deletions test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ Matcher throwsZoned(matcher) => predicate((void Function() callback) {

/// A matcher that runs a callback in its own zone and asserts that that zone
/// emits a [TypeError].
final throwsZonedCastError = throwsZoned(TypeMatcher<TypeError>());
final throwsZonedTypeError = throwsZoned(TypeMatcher<TypeError>());

/// A matcher that matches a callback or future that throws a [TypeError].
final throwsCastError = throwsA(TypeMatcher<TypeError>());
final throwsTypeError = throwsA(TypeMatcher<TypeError>());

/// A badly behaved stream which throws if it's ever listened to.
///
Expand Down