Commit graph

21 commits

Author SHA1 Message Date
Alexander Markov 65254a4518 [nnbd/corelib] Fix performance regressions due to casts in 'get current' in iterators
Fixes https://github.com/dart-lang/sdk/issues/40877

Change-Id: I6ae70ba53bccf6634953adcba6e92554236d82ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138327
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2020-03-04 21:07:16 +00:00
Vijay Menon 7aa824076c [nnbd/collection] remove incorrect cast
This turned up when we fixed a strong mode bug in DDC (which used to skip this check):

https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket.appspot.com/8887565601020813776/+/steps/test_results/0/logs/new_test_failures__logs_/0

The casts look incorrect, so removing.

Change-Id: I6ea45e60a84417fa630bb849020e66bd503b1d00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137041
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2020-02-25 02:02:20 +00:00
Robert Nystrom 6ef9131d82 Fix the migrated splay_tree.dart to make some casts nullable.
I think the covers the cases where it seems reasonable for the value
being cast to be null. In the other places where I see casts, it's
pretty clear that a null is an error.

Change-Id: I38e9b47da72579e7f3849284689d4c25b5b14af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136725
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2020-02-21 02:24:46 +00:00
Robert Nystrom 156c503620 Change indexOf() and lastIndexOf() back to Object.
In the legacy SDK these two methods in ListMixin take Object, not E.
When I migrated them to NNBD, I changed them to E to match the
declaration of the methods in List. This was an unintended breaking
change.

Fix that by changing them to "Object?", which is the NNBD equivalent of
the declarations in the legacy SDK.

Change-Id: I2a75e9f26a8198e4f51cb32a55055d5e64a69ed1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136412
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2020-02-20 09:00:17 +00:00
Lasse Reichstein Holst Nielsen 76b18c455e Make DoubleLinkedQueue.firstEntry/lastEntry nullable again.
It was migrated to null-safety by throwing, but that's an unnecessary breaking change.

Change-Id: I92c21d7518bf7c291b333b33a04eb4b21b7cc210
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134725
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2020-02-11 06:59:11 +00:00
Liam Appelbe b86c6e0ce9 [lib] Fix some NNBD lib tests
Fixes:
lib_2/convert/ascii_test
lib_2/convert/latin1_test
lib_2/typed_data/typed_data_list_test
Change-Id: I493ef6e43db71f09e147b21cbaabdf6a47d833de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134780
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2020-02-10 18:06:40 +00:00
Lasse Reichstein Holst Nielsen 95511b314c Stop using List() constructor in NNBD code.
The List constructor has been disallowed in NNBD code, so the NNBD SDK
should not be using it.

This changes all uses, not just in the already migrated libraries.
(Also found some bad typing in the `RegExpMatch` class along the way).

Change-Id: Ic61bd64427c0961c23aaf7ce59af5c2c271890ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132282
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-01-24 15:59:29 +00:00
Mark Zhou fdba2483b2 Moving DoubleLinkedQueueEntry's null check to firstEntry and lastEntry.
Change-Id: I9fa24ca0a5ff430a2070c9d754adb0751ba545f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132407
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2020-01-21 22:01:39 +00:00
Vlad Doster de87449847 docs(Update list.dart)
Referencing #37793
Updated so that the comments no longer point to a deprecated collection.

Closes https://github.com/dart-lang/sdk/pull/40235
https://github.com/dart-lang/sdk/pull/40235

GitOrigin-RevId: 7ed75046e5e2cc1196cad5093b1fae0825539904
Change-Id: I7cd512025b707e8532bcdd1af08f3b3ba70327af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132620
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2020-01-21 12:17:52 +00:00
Lasse R.H. Nielsen 8b4a4e470f Make the NNBD List.empty default to non-growable.
Since a growable list can be created using `[]`, you never need to call
`List.empty` with anything but `growable: false` or `growable: dynamicValue`.
That means that the default should be non-growable (which also matches
`List.filled` and apparently user expectations - since there is already one bug where
I assumed it would be non-grwowble while migrating List.generate).

Ensure it's implemented by dart2js too and used where there were comments
saying to use it when available.

Change-Id: Ied20d69346ecfb93640ee2cec718e30e6f8980e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132600
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2020-01-20 20:19:18 +00:00
asiva 7e6939643d [VM/patch libraries] - Fix analyzer errors/warnings.
Change-Id: Ia3a7df0801df3b17685df0389a299acb4134d972
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132307
Commit-Queue: Siva Annamalai <asiva@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-01-18 02:37:08 +00:00
Vijay Menon 05632be0ce [nnbd/collection] fix infinite loop in nnbd sdk
See https://dart-ci.appspot.com/log/ddc-nnbd-linux-release-chrome/dartdevk-weak-linux-release-chrome/1460/corelib_2/collection_of_test

Change-Id: I5575cb1db89985f5dc84343412835cccc54b9d47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132160
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Vijay Menon <vsm@google.com>
2020-01-16 22:19:08 +00:00
Mark Zhou a0393edd6a Inlining list copy in Queue.toList.
Change-Id: I2fdf9a780365b52ebea9810752e053cd94b5bfe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130100
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-01-03 18:26:59 +00:00
Nicholas Shahan bef857b6cb Fix dart:collection analysis errors in NNBD fork
Change-Id: Id4a5e5b100ca1c429070263555ab730622644d19
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127161
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2019-12-05 18:20:09 +00:00
Mark Zhou a4bac1fb10 [dartdevc] Migrating dart:_js_helper and dart:_interceptors to NNBD.
Subsumes the reland of https://dart-review.googlesource.com/c/sdk/+/125994

Change-Id: Ie12c8d473303d0ce7379828caf7523b26733ab75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126610
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2019-12-04 18:23:29 +00:00
Robert Nystrom b8cd8eee5d Migrate dart:internal to NNBD.
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>
2019-11-05 19:21:23 +00:00
Robert Nystrom 34e8595362 Migrate the forked version of dart:collection to NNBD... mostly.
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>
2019-10-23 20:53:55 +00:00
Sam Rawlins 04702d827b Fix Queue.from doc comment
Fixes #37943

Change-Id: I6812ba3c3ccc8e679b9bcbb2d6ad5e4d14035cd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122482
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2019-10-23 10:03:55 +00:00
Sam Rawlins fd0617bd98 Improve listToString and setToString documentation. Fixes #26529
Bug: https://github.com/dart-lang/sdk/issues/26529
Change-Id: I4e2994dd39c676c2136c82d3e5dd9f45a8b154ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/82784
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
2019-10-18 18:15:52 +00:00
Lasse R.H. Nielsen e88057fe04 Add non-NNBD language version marker on all sdk_nnbd files.
Change-Id: I2ab3d4b1efe0f3c79f4b770e79476153380220f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118040
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
2019-09-19 19:44:37 +00:00
Paul Berry 004d49bd6b Make a fork of sdk/lib for use by NNBD.
Change-Id: I7f5892d66f9e7bd08ca064fb2df329794a56faf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/116527
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-09-10 19:20:12 +00:00