Also caught a couple of mistakes I made in dart:collection which got
picked up by this because some classes in here use classes from there.
Change-Id: I799db57baf4ea97e8ad4700008918acf03956aff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123600
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
I ended up using nullable types and "!" (or "as E" because "!" has a
bug right now) in most cases to fix the nullability errors. There is
probably a more elegant refactoring one could do around things like the
sentinel nodes, but this preserves the existing behavior, doesn't break
any APIs and is minimally invasive.
It's not perfect, but it's progress and we can land and iterate on it.
Other changes:
- Filled in dynamic for raw types. No particular reason, but it seemed
clearer to me, and I noticed in places where I was getting errors
about implicit casts from dynamic.
- Added some "dynamic" type annotations on lambdas. I was surprised
those are needed since I expected inference to fill in the type, but
if I don't annotate, I get "Missing parameter type for '_'."
- Made optional parameters nullable. When the parameter was a function
type, I also switched to the new function type syntax since using "?"
on the old C-style syntax looks pretty strange to me.
- Fixed many many implicit downcast errors. In some cases, no cast was
needed and I could loosen the target type to get rid of the cast. In
other cases, I added an explicit cast.
- Got rid of "new" in doc comments.
There are still a few errors. They are either:
- Invalid override errors from stuff in dart:core. I think these will
go away once core is migrated too.
- Errors caused by #38813.
- An error that I think it caused by #38900.
Observations:
- I found a few cases where implicit downcasts were happening
unintentionally. They didn't fail but there was no need to use the
tighter type there.
- It was annoying to work around List<E>(size) being prohibited on a
nullable type, but not particularly painful. This library is probably
the most affected by that restriction and it wasn't that bad.
- Having both explicit downcasts *and* type annotated local variables
is really silly. It's a good thing most users use "var" and "final".
- Analyzer error messages were almost always precise, clear, and well
located. The one exception is that the invalid override errors are
really strange looking and don't tell you why the types don't match.
- Migrating code you're completely unfamiliar with is a little
uncomfortable, but still surprisingly doable. You can almost always
fix an error with some local change and little global context.
- I only used "late" once. That's probably mostly a consequence of me
not knowing the code well and trying to make minimal changes.
Change-Id: Ifaedd0d4203945fd0b5ce20145c6e10b8ac1d646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121920
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>