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

Issue 1947923003: Add APIs for asserting the types of transformers. (Closed)

Created:
4 years, 7 months ago by nweiz
Modified:
4 years, 7 months ago
CC:
reviews_dartlang.org
Base URL:
git@github.com:dart-lang/async.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Add APIs for asserting the types of transformers. I thought about adding these to Delegating*Transformer classes, but those delegates don't really make any sense at all on their own, so I found other places instead. R=lrn@google.com Committed: https://github.com/dart-lang/async/commit/a4e67957e6807916526a76120852a69f28fc2ac6

Patch Set 1 #

Total comments: 6

Patch Set 2 : Code review changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+76 lines, -1 line) Patch
M CHANGELOG.md View 1 chunk +10 lines, -0 lines 0 comments Download
M lib/async.dart View 1 chunk +1 line, -0 lines 0 comments Download
M lib/src/stream_sink_transformer.dart View 2 chunks +14 lines, -0 lines 0 comments Download
A lib/src/stream_sink_transformer/typed.dart View 1 1 chunk +20 lines, -0 lines 0 comments Download
A lib/src/typed_stream_transformer.dart View 1 chunk +30 lines, -0 lines 0 comments Download
M pubspec.yaml View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7 (1 generated)
nweiz
4 years, 7 months ago (2016-05-04 21:27:23 UTC) #1
nweiz
Friendly ping!
4 years, 7 months ago (2016-05-09 19:12:09 UTC) #2
Lasse Reichstein Nielsen
lgtm https://codereview.chromium.org/1947923003/diff/1/lib/src/stream_sink_transformer.dart File lib/src/stream_sink_transformer.dart (right): https://codereview.chromium.org/1947923003/diff/1/lib/src/stream_sink_transformer.dart#newcode61 lib/src/stream_sink_transformer.dart:61: : new TypeSafeStreamSinkTransformer(transformer); I still want <S, T> ...
4 years, 7 months ago (2016-05-09 19:20:12 UTC) #3
nweiz
Code review changes
4 years, 7 months ago (2016-05-09 19:31:17 UTC) #4
nweiz
Committed patchset #2 (id:20001) manually as a4e67957e6807916526a76120852a69f28fc2ac6 (presubmit successful).
4 years, 7 months ago (2016-05-09 19:31:50 UTC) #6
nweiz
4 years, 7 months ago (2016-05-09 19:31:51 UTC) #7
Message was sent while issue was closed.
https://codereview.chromium.org/1947923003/diff/1/lib/src/stream_sink_transfo...
File lib/src/stream_sink_transformer.dart (right):

https://codereview.chromium.org/1947923003/diff/1/lib/src/stream_sink_transfo...
lib/src/stream_sink_transformer.dart:61: : new
TypeSafeStreamSinkTransformer(transformer);
On 2016/05/09 19:20:12, Lasse Reichstein Nielsen wrote:
> I still want <S, T> on this constructor call so the class also works in spec
> mode.
> The purpose of the class is to add extra type checks, so if it doesn't do that
> at all in spec mode, it's just not useful. That differs from cases where the
> extra type parameter is just used for validation and the class still works
> without them - here the purpose of the class is the validation.

This clause can't be reached in spec mode. The input always has type
[StreamTransformer], and the is check isn't generic in spec mode, so this will
always return [transformer] unmodified.

https://codereview.chromium.org/1947923003/diff/1/lib/src/stream_sink_transfo...
File lib/src/stream_sink_transformer/typed.dart (right):

https://codereview.chromium.org/1947923003/diff/1/lib/src/stream_sink_transfo...
lib/src/stream_sink_transformer/typed.dart:11: /// transformer.
On 2016/05/09 19:20:12, Lasse Reichstein Nielsen wrote:
> "coerces" isn't specific enough. At least say what it is coerced to.

Done.

https://codereview.chromium.org/1947923003/diff/1/lib/src/typed_stream_transf...
File lib/src/typed_stream_transformer.dart (right):

https://codereview.chromium.org/1947923003/diff/1/lib/src/typed_stream_transf...
lib/src/typed_stream_transformer.dart:14: /// provided. If they're not, the
stream throws a [CastError].
On 2016/05/09 19:20:12, Lasse Reichstein Nielsen wrote:
> Also say that t expects the argument to bind to be a Stream<S> (but it doesn't
> actually check that the events are S instances).

This isn't really an aspect of the behavior of the transformer (at least in
strong mode, which is the only mode in which wrapping can actually happen). The
bind() method is annotated as Stream<S>, but that's already statically required
by the fact that this returns a StreamTransformer<S, T>—there's no way for
bind() to actually receive an argument with any other type.

Powered by Google App Engine
This is Rietveld 408576698