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

Issue 1841223002: Fix most strong mode warnings. (Closed)

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

Description

Fix most strong mode warnings. The remaining warnings will need type-asserting wrappers to fix, which are coming in a separate CL. R=lrn@google.com Committed: https://github.com/dart-lang/async/commit/783a5f6bb3d2a11e5923fbd7fc47ec89dcc1824c

Patch Set 1 #

Total comments: 24

Patch Set 2 : #

Patch Set 3 : Code review changes #

Unified diffs Side-by-side diffs Delta from patch set Stats (+143 lines, -126 lines) Patch
A .analysis_options View 1 chunk +2 lines, -0 lines 0 comments Download
M CHANGELOG.md View 1 chunk +18 lines, -0 lines 0 comments Download
M lib/src/async_memoizer.dart View 1 chunk +1 line, -1 line 0 comments Download
M lib/src/cancelable_operation.dart View 1 2 1 chunk +3 lines, -3 lines 0 comments Download
M lib/src/delegate/future.dart View 1 chunk +4 lines, -4 lines 0 comments Download
M lib/src/result.dart View 1 2 4 chunks +15 lines, -27 lines 0 comments Download
M lib/src/result/capture_transformer.dart View 1 chunk +4 lines, -1 line 0 comments Download
M lib/src/result/error.dart View 2 chunks +4 lines, -4 lines 0 comments Download
M lib/src/result/future.dart View 1 chunk +5 lines, -4 lines 0 comments Download
M lib/src/result/value.dart View 1 chunk +1 line, -1 line 0 comments Download
M lib/src/single_subscription_transformer.dart View 1 chunk +14 lines, -3 lines 0 comments Download
M lib/src/stream_completer.dart View 3 chunks +5 lines, -5 lines 0 comments Download
M lib/src/stream_group.dart View 1 2 3 chunks +5 lines, -5 lines 0 comments Download
M lib/src/stream_queue.dart View 14 chunks +35 lines, -35 lines 0 comments Download
M lib/src/stream_sink_completer.dart View 1 chunk +3 lines, -2 lines 0 comments Download
M lib/src/stream_sink_transformer/handler_transformer.dart View 1 chunk +1 line, -5 lines 0 comments Download
M lib/src/stream_splitter.dart View 1 2 2 chunks +7 lines, -7 lines 0 comments Download
M lib/src/stream_zip.dart View 3 chunks +8 lines, -8 lines 0 comments Download
M lib/src/subscription_stream.dart View 1 2 3 chunks +6 lines, -9 lines 0 comments Download
M pubspec.yaml View 1 2 2 chunks +2 lines, -2 lines 0 comments Download

Messages

Total messages: 12 (1 generated)
nweiz
4 years, 8 months ago (2016-03-29 21:04:19 UTC) #1
Lasse Reichstein Nielsen
LGTM, even if I don't think it's an improvement. https://codereview.chromium.org/1841223002/diff/1/lib/src/delegate/future.dart File lib/src/delegate/future.dart (right): https://codereview.chromium.org/1841223002/diff/1/lib/src/delegate/future.dart#newcode10 lib/src/delegate/future.dart:10: ...
4 years, 8 months ago (2016-03-29 21:53:59 UTC) #2
nweiz
Code review changes
4 years, 8 months ago (2016-03-30 00:56:19 UTC) #3
nweiz
https://codereview.chromium.org/1841223002/diff/1/lib/src/delegate/future.dart File lib/src/delegate/future.dart (right): https://codereview.chromium.org/1841223002/diff/1/lib/src/delegate/future.dart#newcode10 lib/src/delegate/future.dart:10: final Future<T> _future; On 2016/03/29 21:53:59, Lasse Reichstein Nielsen ...
4 years, 8 months ago (2016-03-30 00:57:19 UTC) #4
nweiz
Committed patchset #3 (id:40001) manually as 783a5f6bb3d2a11e5923fbd7fc47ec89dcc1824c (presubmit successful).
4 years, 8 months ago (2016-03-30 00:57:27 UTC) #6
Lasse Reichstein Nielsen
https://codereview.chromium.org/1841223002/diff/1/lib/src/result/error.dart File lib/src/result/error.dart (right): https://codereview.chromium.org/1841223002/diff/1/lib/src/result/error.dart#newcode30 lib/src/result/error.dart:30: Future<T> get asFuture => new Future.error(error, stackTrace); That doesn't ...
4 years, 8 months ago (2016-03-30 16:00:18 UTC) #7
nweiz
https://codereview.chromium.org/1841223002/diff/1/lib/src/result/error.dart File lib/src/result/error.dart (right): https://codereview.chromium.org/1841223002/diff/1/lib/src/result/error.dart#newcode30 lib/src/result/error.dart:30: Future<T> get asFuture => new Future.error(error, stackTrace); On 2016/03/30 ...
4 years, 8 months ago (2016-03-30 19:11:54 UTC) #8
Lasse Reichstein Nielsen
On 2016/03/30 19:11:54, nweiz wrote: > https://codereview.chromium.org/1841223002/diff/1/lib/src/result/error.dart > File lib/src/result/error.dart (right): > > https://codereview.chromium.org/1841223002/diff/1/lib/src/result/error.dart#newcode30 > ...
4 years, 8 months ago (2016-03-30 22:18:11 UTC) #9
nweiz
On 2016/03/30 22:18:11, Lasse Reichstein Nielsen wrote: > I mean non-strong-mode Dart, and while `Future<dynamic> ...
4 years, 8 months ago (2016-03-30 22:52:29 UTC) #10
Lasse Reichstein Nielsen
On 2016/03/30 22:52:29, nweiz wrote: > On 2016/03/30 22:18:11, Lasse Reichstein Nielsen wrote: > > ...
4 years, 8 months ago (2016-03-30 23:54:22 UTC) #11
nweiz
4 years, 8 months ago (2016-03-31 22:52:40 UTC) #12
Message was sent while issue was closed.
On 2016/03/30 23:54:22, Lasse Reichstein Nielsen wrote:
> On 2016/03/30 22:52:29, nweiz wrote:
> > On 2016/03/30 22:18:11, Lasse Reichstein Nielsen wrote:
> > > I mean non-strong-mode Dart, and while `Future<dynamic> is Future<T>` I
want
> > the
> > > result to also satisfy that it `is! Future<not-T>`, and fail in checked
mode
> > if
> > > you call `.then((notT x) => something)` on it because it expects a
> > T->something
> > > function.
> > 
> > Why? It's extremely non-conventional to use is checks on generics in
general,
> > and even more so on futures in particular. The same is true for typing the
> > callback argument to then(), especially now that async/await exists.
> 
> For the same reason we have type parameters everywhere else, and why we make
> sure to return a List<int> from `new List<int>` instead of a just a
> `List<dynamic>` - because it is a more precise type, and it allows catching
> errors earlier - and it prevents errors in the few cases where someone does do
> an `is List<String>` on what was intended to be just a `List<int>`.
> 
> We generally try to have the correct type parameters on objects we create.
> 
> Otherwise we could just remove all type parameters at runtome, which we are
not
> doing (and as far as I know are not (yet) planning to do).

This may be true for collections, but it's definitely not true for futures. In
spec-mode, futures almost universally have dynamic as their reified type because
that's what all the methods as well as async/await produced. It's categorically
unsafe to rely on the reified types of futures, and there are no
style-guide-compliant situations in which this refied type will help catch
errors.

> > Besides, we're moving towards a strong-mode-only world. I don't think it
makes
> > sense to add extra annotations that only make sense in checked or unchecked
> > modes when they're going away anyway.
> 
> We are moving towards that (or something like that), but we are not there yet.
> Until then, I prefer to make things both Dart 1.0 and strong-mode compatible.
> The annotations should be harmless in strong-mode.

I agree that we should write code to be spec-mode compatible for now—and the
existing code without the extra annotation is that. What I don't think we should
do is add extra code that will be useless in strong mode just to get slightly
better spec-mode checking in a situation that's very unlikely to occur in
practice.

Powered by Google App Engine
This is Rietveld 408576698