Commit graph

1289 commits

Author SHA1 Message Date
Konstantin Shcheglov 4c6f5f7658 Remove NullSafetyUnderstandingFlag.
Bug: https://github.com/dart-lang/sdk/issues/40531

Change-Id: I197cfdf64c697a09bb9e0e3896f3ee5ac1967757
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168160
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-02 18:03:24 +00:00
Paul Berry a42244f73b Flow analysis: begin tracking non-promotion reasons.
This CL implements the core flow analysis infrastructure for tracking
reasons why an expression was not promoted.  It supports the following
reasons:

- Expression was a property access
- Expression has been written to since it was promoted

I expect to add support for other non-promotion reasons in the future,
for example:

- `this` cannot be promoted
- Expression has been write captured
- Expression was a reference to a static field or top level variable

These non-promotion reasons are plumbed through to the CFE and
analyzer for the purpose of making errors easier for the user to
understand.  For example, given the following code:

  class C {
    int? i;
    f() {
      if (i == null) return;
      print(i.isEven);
    }
  }

The front end now prints:

  ../../tmp/test.dart:5:13: Error: Property 'isEven' cannot be accessed on 'int?' because it is potentially null.
  Try accessing using ?. instead.
      print(i.isEven);
              ^^^^^^
  Context: 'i' refers to a property so it could not be promoted.

Much work still needs to be done to round out this feature, for example:

- Currently the analyzer only shows the new "why not promoted"
  messages when the "--verbose" flag is specified; this means the
  feature is unlikely to be noticed by users.

- Currently the analyzer doesn't show a "why not promoted" message
  when the non-promotion reason is that the expression is a property
  access.

- We need one or more web pages explaining non-promotion reasons in
  more detail so that the error messages can contain pointers to them.

- The analyzer and front end currently only show non-promotion reasons
  for expressions of the form `x.y` where `x` fails to be promoted to
  non-nullable.  There are many other scenarios that should be
  handled.

Change-Id: I0a12df74d0fc6274dfb3cb555abea81a75884231
Bug: https://github.com/dart-lang/sdk/issues/38773
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/181741
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-02-02 16:15:34 +00:00
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00
Paul Berry 06682de751 Migration: Additional test cases for extension overrides.
These test cases were accidentally left out of
8ad4919482.

Change-Id: I2986e7d2763ff2ee0eea4800da185a5d45d69e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180401
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-22 22:04:54 +00:00
Sam Rawlins aeb040fe75 dart migrate: Fix dead code; add test
Change-Id: I1cc015d4bf66c4810a2cb9a161018b075f317176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180602
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-22 18:14:23 +00:00
Sam Rawlins 97df2e6031 dart migrate: Tidy up extra newlines in opt-out comment
Change-Id: If0c2a2c98d3284da847cae40d1ae8fad97abce6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180482
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-22 16:22:03 +00:00
Sam Rawlins f6fc66d674 dart migrate: Opt the web app out of null safety
This is needed as the web app (just migration.dart) is viewed as a
stand-alone Dart file, and thus is de facto opted in.

Change-Id: I56930cc95d32ab22d2ade3c174023775a1f44771
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180483
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-22 15:28:33 +00:00
Paul Berry 25af65bb91 Fix exception handling in EdgeBuilder._dispatch.
Previously, we did not null check the listener, which meant that if an
exception occurred in a unit test, there would be a cascading
exception, so we wouldn't get a useful stack trace.

Change-Id: I612ca9e7129441e319d92953c481fd1647eb46ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180383
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-21 21:30:33 +00:00
Paul Berry 454143db3a Migration: Test explicit extension syntax for #42529.
These tests were accidentally left out of
a93a9a05a8.

Bug: https://github.com/dart-lang/sdk/issues/42529
Change-Id: Ie101d171d2eb2179621831d7ba71ad6598ecd3aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180420
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-21 21:29:32 +00:00
Paul Berry a93a9a05a8 Migration: handle references to property accessors in extensions.
Fixes #42529.

Bug: https://github.com/dart-lang/sdk/issues/42529
Change-Id: I46be5511bf3929ba08da62bdc6ac6c85a307d0ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180400
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-21 19:04:12 +00:00
Paul Berry 5569f10236 Migration: infer non-null intent for this in extensions.
Since `this` is essentially a variable in extensions, it should be
treated similarly to variables in terms of inference of non-null
intent; for example, if an extension declaration contains a a method
that unconditionall dereferences `this` (either implicitly or
explicitly), that's a good indication that the user probably doesn't
intend for the extension to be applied to nullable types.

Fixes #44675.

Bug: https://github.com/dart-lang/sdk/issues/44675
Change-Id: I004328f5b1fd6710954363c07f4e9db6bc6ac2cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180268
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-21 13:33:36 +00:00
Paul Berry db367e728c Sort declarations in edge_origin.dart
Change-Id: I9461d6af29900546cff74879e95f8d729497080b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180283
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-01-21 13:33:36 +00:00
Paul Berry 46fc6ae07c Migration: refactor _ScopedLocalSet so that all conversion from expressions to elements is in one place.
This will pave the way for expanding this logic to handle `this` in
extension methods.

Bug: https://github.com/dart-lang/sdk/issues/44675
Change-Id: I965c28261eb27807e6789b5906a026c5367d8217
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180281
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-01-21 13:33:36 +00:00
Paul Berry 8ad4919482 Null safety migration: don't null check calls to extensions that permit null.
This partially addresses #44675 by ensuring that if an extension's
extended type is nullable, we won't try to insert an unnecessary null
check at the call site.

It's not a complete fix, though, because we still don't account for
obvious indications of non-null intent when analyzing the extension
definition itself.  I plan to address that in future CLs.

Bug: https://github.com/dart-lang/sdk/issues/44675
Change-Id: Ia0ca37b89470a2d4882ae32cd842552ffd34930e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180263
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-01-21 13:33:36 +00:00
Sam Rawlins 8833210ee4 dart migrate: Only opt out files with a comment if they appear in files-to-process
Change-Id: I3cb1bedaa4a03eca89e29528c554488955f2bb04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180083
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-21 00:57:33 +00:00
Sam Rawlins f6dba2b25f dart migrate: Separate HintAction and HintActionKind into separate file
This addresses a cyclic dependency build issue in google3.

Change-Id: I3ea917f7216e120b827577bde60b874a9bad52af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180240
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2021-01-20 21:54:53 +00:00
Paul Berry 21bc3980fd Null safety migration: fix non-null intent in the presence of write captures.
After a variable is write captured, references to it should no longer
be considered to express non-null intent, because we can no longer
guarantee that an initially null value of the variable would
definitely lead to an exception.

Change-Id: I44c65350291a4c44cdb4b19529b13149d8170e34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180100
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-20 14:15:15 +00:00
Paul Berry 5df3d0f5f7 Null safety migration: fix non-null intent inference in the presence of local functions.
Previously, code inside of local functions was treated as though it
appeared inline for the purpose of determining non-null intent.  As a
result, a return statement in such a local function would cause any
code references that followed to be incorrectly treated as *not*
expression non-null intent.

Fixes #44703.

Bug: https://github.com/dart-lang/sdk/issues/44703
Change-Id: Ia74da007eb5424c784d41afeb0e2da4771578553
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-20 05:40:26 +00:00
Paul Berry 306eb2fd97 Null safety migration: fix late inference when there is non-null intent
Previously, the nullability graph propagation algorithm identified
non-null intent prior to inference of `late`.  As a result, late
inference would be skipped for any variable with clear non-null
intent, so late inference was a lot less effective than it should be.

This requires updating several test cases where `late` should have
been inferred.

Change-Id: I0412ee7045e654185af08cc12b6ca1e6866112af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180080
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-01-20 05:40:26 +00:00
Sam Rawlins 3bd63a4d52 dart migrate: add a dart2js_path option to the resource generator
This helps build the web app in google3.

Change-Id: Ia5650836b2df37cff7b76f1cc7877776d6210790
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180086
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-20 01:10:26 +00:00
Sam Rawlins d97be105f8 dart migrate: Do not attempt to edit migration status icons for external files
Fixes https://github.com/dart-lang/sdk/issues/44705

Change-Id: I993726795391a2d5d0e639e5db56d10b6809ee79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179921
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-19 19:11:22 +00:00
Paul Berry 011f98c959 Invoke flow analysis for if-elements during null safety migration.
Fixes #44702.

Bug: https://github.com/dart-lang/sdk/issues/44702
Change-Id: I70e50722572553dca42b21cea9aff010bd978bfe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-19 18:20:32 +00:00
Sam Rawlins 034540336a dart migrate: insert comment between first comment and first directive
Fixes https://github.com/dart-lang/sdk/issues/44704

Change-Id: I07402a958f7940bb603253a60e43709fc07529b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179920
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-19 15:16:12 +00:00
Paul Berry 8c216921ba Remove transitional method MigrationCliRunner.shouldBeMigrated2
Now that `MigrationCliRunner.shouldBeMigrated` has the correct
signature and internal clients no longer use
`MigrationCliRunner.shouldBeMigrated2`, we can remove
`MigrationCliRunner.shouldBeMigrated2`.

Change-Id: I33bdc78a603c859dd8bf1928f2dbc23233ae5e7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178763
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-19 13:41:32 +00:00
Paul Berry 75aea30724 Add an implementation of legacy type promotion to _fe_analyzer_shared.
The new implementation uses the same API as flow analysis.  This
should allow us to significantly simplify the CFE and analyzer, by
dropping their implementations of legacy type promotion in favor of
the shared implementation.

This CL just introduces the new implementation and unit tests for it;
it does not integrate it with the analyzer or CFE.  I will follow up
with a CL that does the integration.

Change-Id: Ie07b3b39604d6a022ad42f3ae6b648a317c8af28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179560
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-01-16 17:07:23 +00:00
Paul Berry 9de69a94e0 Eliminate context arg from MigrationCliRunner.shouldBeMigrated
This is non-breaking since `shouldBeMigrated` is unreferenced outside
the nnbd_migration package).  Once this lands, we can switch clients
from overriding/calling `shouldBeMigrated2` back to `shouldBeMigrated`
and then eliminate `shouldBeMigrated2`.

Change-Id: I1235113bda6f7609de17ec05e7120b312f201536
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178762
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-16 16:58:43 +00:00
Sam Rawlins bdb60329e9 dart migrate: handle an SDK constraint with no min
Fixed https://github.com/dart-lang/sdk/issues/43989

Change-Id: Iddc5e5f0b53a5ec0540b002654bc46b40dc8a46a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179421
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-15 18:03:07 +00:00
Devon Carew 70a88e9c4f update the documentation url for the nnbd migration tool
Change-Id: Idb898c0b4c831d7304db7b7a5251b9c8e7e66589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179402
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-01-15 16:35:02 +00:00
Nate Bosch 58e7e7eb26 Prepare for breaking change in package:http
The `url` argument is changing from `Object`, accepting either `String`
or `Uri` at runtime, to `Uri` for better static help.
https://github.com/dart-lang/http/pull/507

- Switch to using `Uri` for requests. Where sensible push this type into
  the signature of the surrounding method.
- Make some updated method private where they were unnecessarily public
  which makes it harder to have confidence when looking for usages.
  Rename a method with an unnecessary `get` name.

Change-Id: Ibf075741d6b9d292349b15f1dc84004981729aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179368
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2021-01-15 16:35:01 +00:00
Sam Rawlins 6735d3c693 dart migrate: shutdown the process after applying a migration
Change-Id: Ifdb42cffa703912d541d61ba4386d7df96fda718
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/179240
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2021-01-15 03:32:52 +00:00
Sam Rawlins c5e0e73df5 dart migrate: Fix rendering overlay offset issue in Firefox
Fixes https://github.com/dart-lang/sdk/issues/44635

Change-Id: Id6e0518b86859605c5cfacb9091f7e1ed612b71c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178724
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-12 23:17:33 +00:00
Paul Berry 9370651773 Prepare to eliminate context arg from MigrationCliRunner.shouldBeMigrated
This change changes `MigrationCliRunner.shouldBeMigrated` to forward
to a transitional method `MigrationCliRunner.shouldBeMigrated2`, which
lacks the now-unused `context` argument.  After this lands, internal
clients will be switched to overriding/calling `shouldBeMigrated2`
instead of `shouldBeMigrated`.

Once no clients remain that refer to `shouldBeMigrated`, the `context`
argument will be removed from it (this will be non-breaking since
`shouldBeMigrated` will at that point be unreferenced outside the
nnbd_migration package).  After that, we will switch clients back to
overriding/calling `shouldBeMigrated` and eliminate
`shouldBeMigrated2`.

Change-Id: If9b476878260a5777f3346486d44c805dc361691
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178761
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-12 16:11:21 +00:00
Sam Rawlins 9488ea4c7e dart migrate: support files-to-be-migrated initial state in google3
* Rename isPreviewServerRunnning to isPreviewServerRunning
* Fix top "Migrating" checkbox upon navigation.

This change does not completely solve google3-compatibility, just the
web preview UI portion.

Work to improve any opt-out `// @dart=2.9` comments will follow.

Change-Id: Iee38650ab732179d82060b14bc7b657e3c560543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/178160
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-01-12 05:54:50 +00:00
Brian Wilkerson 6143fb5668 Improve some diagnostic messages
Change-Id: Ic351c2addff76dea8fe49c7e2ce68b46043f0814
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/177480
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-01-04 16:43:08 +00:00
Paul Berry 5c19c9f5e4 Flow analysis: store ExpressionInfo in SSA nodes.
This CL modifies flow analysis API so that when a variable is written
or initialized, if the written expression has non-trivial flow
analysis information, it is captured in the SsaNode associated with
the variable.

The stored information is not yet used; in a follow-up CL, I will add
the ability to retrieve it on a read and use it for promotions.

Bug: https://github.com/dart-lang/language/issues/1274
Change-Id: I1e2590205d4a0c59f4400a119f3d6b380a11414c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-12-17 15:16:04 +00:00
Sam Rawlins 6eddd878c0 dart migrate: Fix preview_site_test on windows
Change-Id: Ib0fc934eb1620017da20a444ced58a8d9e63f540
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-12-15 23:45:01 +00:00
Sam Rawlins fe2205ebde dart migrate: Simplify final output code
Change-Id: Ib472bf14d8dd06efeeb17b2c81fdb97bb886b214
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176340
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-12-15 22:01:11 +00:00
Sam Rawlins 56fb42cb62 dart migrate: enable incremental migration workflow
Also:
* Print out details when applying migration
* Also fix title text position to not scroll out of view.

Change-Id: Idc4b703535400956f78d76ab7959f40cf77a0bc9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175860
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-12-15 17:59:41 +00:00
Konstantin Shcheglov c11039702c Replace FindElement.functionTypeAlias() with typeAlias().
Change-Id: I88a5b889310df8a39b54318907ba8bbd68b26b9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176183
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-15 07:13:41 +00:00
Devon Carew b782d5815f [pkg/nnbd_migration] add types to public API
Change-Id: Ie4a7bbe75dd8045b20361c3fa1e08784b990e951
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176142
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-12-15 01:34:29 +00:00
Konstantin Shcheglov 9717c775e4 Deprecate FunctionTypeAliasElement.function
Change-Id: Id629afa92c6681ba796aed75b24c4251fd86810f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176140
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-14 22:26:29 +00:00
Sam Rawlins 451bd1183b dart migrate: Support Windows newlines in opt out
Also sort test file.

Change-Id: Id8133d699ae1a71d1852ef29ce1f843c7ede98cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175561
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-12-10 00:34:50 +00:00
Sam Rawlins 88de6b438e dart migrate: Implement incremental migration in backend
This is still hiding behind a flag pending final review.

Bug: https://github.com/dart-lang/sdk/issues/44101 and
Change-Id: I01b7cb07b3fde7ac67105034b0c4057cb8a69771
     https://github.com/dart-lang/sdk/issues/44124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/175402
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-12-09 15:21:50 +00:00
Lasse R.H. Nielsen 6e29700e16 Update List constructor documentation, deprecate constructor.
Emphasize that the operation is going away,
and mark constructor as deprecated.

TEST= Refactoring+deprecation only, covered by existing tests.

Change-Id: I82aa044cd2cf7bf347b624371399f44bda8f4a07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173261
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2020-12-07 16:20:28 +00:00
Devon Carew 8cba879f46 Add additional validations to the pkg/ package pubspecs.
TEST=these are additional validations that we run on the bots

Redux of https://dart-review.googlesource.com/c/sdk/+/161040

Change-Id: Ia32ced5d48fbfeafacfa9e51dc4774d2e9425091
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-12-02 17:27:18 +00:00
Paul Berry 1bfcc2d8da Migration: handle for-each loops where the loop variable is not local.
Fixes #44071.

Bug: https://github.com/dart-lang/sdk/issues/44071
Change-Id: I6a1a9df22f70086860c36108e529f189d3d24875
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174565
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-02 15:00:53 +00:00
Sam Rawlins 89811d9a92 Reland "dart migrate: Move title bar and add 'Migrate' check box next to title"
This is a reland of 17226bbbff

Remove generated files

Original change's description:
> dart migrate: Move title bar and add 'Migrate' check box next to title
>
> This check box displays whether a file is migrating, opting out, or
> already migrated. The check box can be clicked to toggle between
> migrating and opting out. Clicking the check box updates status in the
> navigation tree. Clicking on check boxes updates the status in the
> title bar.
>
> Screenshot here: https://screenshot.googleplex.com/9z9v9L5DHhBXzEU.png
>
> In terms of the HTML, a new parent above '.content' div was added:
> the '.file' div, which includes a '.title-bar' div above the '.content'
> div.
>
> Bug: https://github.com/dart-lang/sdk/issues/44101 and
> Change-Id: I021f0dd873119ae801e29faa92e97fe48d03ef3c
> https://github.com/dart-lang/sdk/issues/44124
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174440
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

Bug: https://github.com/dart-lang/sdk/issues/44101 and
Change-Id: Iefada3e2fc8cbbc767cfc539204dc51b369888a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174720
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-12-02 14:40:07 +00:00
Paul Berry 52acf2e8ac Migration: fixes to exception handling.
Since the EdgeBuilder overrides VisitNode, it wasn't getting the
benefit of the error recovery behavior provided by the
PermissiveModeVisitor mixin.  This CL replicates some of the
functionality of PermissiveModeVisitor in the EdgeBuilder._dispatch
method so that it applies throughout the EdgeBuilder's visiting
process.

This uncovered a second bug: when an exception is reported, and the
user hasn't passed in the `--ignore-exceptions` flag, the migration
tool tries to exit immediately by throwing an error of type
MigrationExit, but this was being caught by the error recovery logic,
so the tool wouldn't actually stop reliably.  This CL changes the
exception reporting code so that it re-throws MigrationExit when
necessary to ensure quick termination.

Change-Id: Ifd2faf8edb7cd0087c45e20a747ab7f1790ef1c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174420
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-12-01 16:08:55 +00:00
Konstantin Shcheglov 7c5df72b27 Revert "dart migrate: Move title bar and add 'Migrate' check box next to title"
This reverts commit 17226bbbff.

Reason for revert: has unrelated tools/abiversions changes

Original change's description:
> dart migrate: Move title bar and add 'Migrate' check box next to title
>
> This check box displays whether a file is migrating, opting out, or
> already migrated. The check box can be clicked to toggle between
> migrating and opting out. Clicking the check box updates status in the
> navigation tree. Clicking on check boxes updates the status in the
> title bar.
>
> Screenshot here: https://screenshot.googleplex.com/9z9v9L5DHhBXzEU.png
>
> In terms of the HTML, a new parent above '.content' div was added:
> the '.file' div, which includes a '.title-bar' div above the '.content'
> div.
>
> Bug: https://github.com/dart-lang/sdk/issues/44101 and
> Change-Id: I021f0dd873119ae801e29faa92e97fe48d03ef3c
> https://github.com/dart-lang/sdk/issues/44124
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174440
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,srawlins@google.com

Change-Id: I8b8433d47390df91201a365f5aa54c7fb835d997
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/44101 and
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174385
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-12-01 03:30:32 +00:00
Sam Rawlins 17226bbbff dart migrate: Move title bar and add 'Migrate' check box next to title
This check box displays whether a file is migrating, opting out, or
already migrated. The check box can be clicked to toggle between
migrating and opting out. Clicking the check box updates status in the
navigation tree. Clicking on check boxes updates the status in the
title bar.

Screenshot here: https://screenshot.googleplex.com/9z9v9L5DHhBXzEU.png

In terms of the HTML, a new parent above '.content' div was added:
the '.file' div, which includes a '.title-bar' div above the '.content'
div.

Bug: https://github.com/dart-lang/sdk/issues/44101 and
Change-Id: I021f0dd873119ae801e29faa92e97fe48d03ef3c
https://github.com/dart-lang/sdk/issues/44124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174440
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-12-01 01:36:25 +00:00
Devon Carew 81986f4a36 [dartdev] add a --format option to dart analyze
Change-Id: Iad7d14b12892ce2121430f0cd94a2b0cd0d8e978
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174384
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-12-01 01:32:34 +00:00
Paul Berry 4185e7ccd2 Migration: disable code highlighting for very large files.
This avoids an apparent hang when visiting the SDK file
`html_dart2js.dart` (which happens anytime the user clicks on a link
like `HtmlElement`).

Bug: https://buganizer.corp.google.com/issues/168936042
Change-Id: I52bb535b6a2ca1a74071e272b1276520048a67bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-30 21:30:04 +00:00
Paul Berry e047dd60d6 Ensure that function elements inside local variable elements have unique locations.
Fixes #44216.

Bug: https://github.com/dart-lang/sdk/issues/44216
Change-Id: I5ccf8bb5f90396eabfec470a289a193d2aef16ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173881
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-25 13:39:04 +00:00
Sam Rawlins 1b07887853 Migrator: Implement check boxes on directories
Checking and unchecking a directory toggles the status of all child files which
are 'migrating' or 'opting out.' Files which are already migrated do not
change.

Checking and unchecking a file updates the status of all parent directories.
Directories with both 'migrating' and 'opting out' files are 'indeterminate'.

The difference between 'file' and 'directory' NavigationTreeNodes was
getting too hairy so I split into two subclasses.

Removed the keepingOptedOut status and added the indeterminate status.

Bug: https://github.com/dart-lang/sdk/issues/44101
Change-Id: Iea1a8c07b08c3d7956db51ca372437093457fe7f
     https://github.com/dart-lang/sdk/issues/44124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173600
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-11-25 02:32:59 +00:00
Paul Berry f0d56055b6 Migration: handle is expressions where the type is a function type.
Change-Id: Ibdcb4a49bd51e218e58a52a3e2f32bef55bce61e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173020
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-20 12:26:36 +00:00
Sam Rawlins db0a23faa0 Migrator: Land front-end support for 'migration status' check boxes
These check boxes are hidden behind a parameter that must be changed during
development; it is not wired to a public-facing flag.

The check boxes are styled, and are connected to the starting status of each
compilation unit (already migrated, opted out, migrating).

The check boxes can be toggled, but just for mocking purposes; their status is
not connected to the back end. The directory check boxes are not wired to the
status of their children.

Screenshot of checkboxes w/o colors: https://screenshot.googleplex.com/43XBRWsMPgbQXik

Screenshot of check boxes w/ colors: https://screenshot.googleplex.com/3bhJqcnmeV4sGNm
* dark green - already migrated; file is not being changed.
* light green - file is being migrated now.
* orange un-checked - file is being opted out, initial migration,
  file will gain opt-out comment.
* grey un-checked - staying opted out, file is not being changed.
* indeterminate - folder has multiple states inside.

Bug: https://github.com/dart-lang/sdk/issues/44124 and
Change-Id: I49daf1f52544024ec1c6d8d5cf3c59515c7db3a7
     https://github.com/dart-lang/sdk/issues/44101
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172821
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-11-19 19:32:25 +00:00
Paul Berry d0a23d8106 Add a triage document for the dart migrate tool.
Change-Id: I4ba33889c6171d012fc6a4239f4409c5fe9de005
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172661
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2020-11-17 21:39:48 +00:00
Sam Rawlins 95e4e03f88 Migrator: do not generate edit details twice on rerun
Fixes https://github.com/dart-lang/sdk/issues/44086

Change-Id: I99a23e5922a716bbd0c83e7c0f620686840ccd4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172300
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-17 05:05:00 +00:00
Nate Bosch aaf13b5247 Update to the latest package:yaml
Expand the range allowed by the dep from `package:analyzer`.

Switch dependencies to `any` for the packages which are `publish_to:
none`. The actual constraints aren't useful in these packages since they
are always pinned exactly by DEPS and so we can't trust they are kept up
to date.

Change-Id: Ibd937e8646574d49105f4dd0de2529e7ab30862a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172380
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2020-11-16 22:16:50 +00:00
Paul Berry 4bde77e3c4 Migration: fix test_this_inside_extension.
This functionality is working now, the test was just broken.

Bug: https://github.com/dart-lang/sdk/issues/39387
Change-Id: I088a3bd40ac438d0a9cd2356badfaf9513aa4bbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172280
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-16 21:21:06 +00:00
Paul Berry c0586277d7 Migration: fix handling of extensions on generic and function types
Bug: https://github.com/dart-lang/sdk/issues/39387
Change-Id: I037d29355dc86c071acc8dcc6f417a95e96e9728
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172200
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-16 17:11:58 +00:00
Paul Berry 3103e1e0f6 Migration: don't overcount "whereOrNull" fixes.
Fixes #44174.

Bug: https://github.com/dart-lang/sdk/issues/44174
Change-Id: Ida53a11afc2e265cd510b0ac63c50f6b5ac93fdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171962
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-13 18:51:30 +00:00
Paul Berry 8abc99d07a Migration: encourage user to include SDK version when filing bugs
Change-Id: Ib8056827595470d8c3c8b2cb8371ab08dcc3e651
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172040
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2020-11-13 18:18:10 +00:00
Paul Berry 7d3bc4862d Rename pkg/analysis_tool to pkg/analyzer_utilities.
It's no longer just for the tools in the `tool` directory; it also
contains test utilities for use by the analyzer and related packages.

Change-Id: I0f8cf57f24ea7aad8e2177e43ee2bcb2ab3030da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171704
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-13 17:46:30 +00:00
Paul Berry b3120a6170 Sort declarations in messages.dart.
Change-Id: I07840b0818f36d6db9e099c69e02083ed3a8845d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171980
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-13 17:38:10 +00:00
Paul Berry cf4d300c0b Migration: handle "already migrated" case more gracefully.
If all the user's code has already been migrated and there are no
errors, instead of crashing, produce a friendly message indicating
that there's nothing to do, and exit cleanly.

Fixes #44193.

Bug: https://github.com/dart-lang/sdk/issues/44193
Change-Id: I9da9ab0221d4e13a61985eaa3fec0e74b86e9072
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171960
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-13 17:38:10 +00:00
Paul Berry 0258778e3b Migration: explain that user may make edits in their IDE
Change-Id: I8289aa274a7882a41a5411739999f1db77fc196f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172000
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
2020-11-13 15:44:10 +00:00
Paul Berry 02b2e5398d Migration: permanently enable "transform where or null" feature.
This feature is now working reliably enough that we no longer need the
option of turning it off.

Change-Id: I2bbeb114ca1bd4e0dc8e94ac6775ec5e2fa8718e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171705
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-12 21:12:20 +00:00
Paul Berry 80ac9c999b Migration: update pubspec when adding import of package:collection.
Change-Id: Ia9e5090bafa7f67be87aa01367bec16f4fd80ee9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171701
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-12 21:12:20 +00:00
Paul Berry fdfcab8581 Rework DartFixListener callbacks to use an interface class.
I will need to add another callback in a follow-up CL, and it seems
silly to pass a bunch of closures to the DartFixListener constructor.

Change-Id: I969d1d90fca0889b131589248aaa1cec343a9059
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171700
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-12 21:12:20 +00:00
Paul Berry 95940f8963 Sort declarations in migration_cli.dart and nnbd_migration.dart
Change-Id: I4e2904a40dcc0f7ece94ee6aa823743455f46b4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171633
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-12 18:07:09 +00:00
Paul Berry 83cf6d67dc Migration: improve error/warning text when there are analysis errors.
Fixes #44144

Bug: https://github.com/dart-lang/sdk/issues/44144
Change-Id: I54ef9ca8f38335df2082d730ba558fd407a07767
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171643
Commit-Queue: Kathy Walrath <kathyw@google.com>
Reviewed-by: Kathy Walrath <kathyw@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
2020-11-12 17:59:07 +00:00
Paul Berry e205acb506 Migration: stop recommending --prereleases with pub outdated --mode=null-safety.
As of
5fba201573,
`--mode=null-safety` implies `--prereleases`.

Change-Id: I34bc827ddd3579e968276f826c0420ffadc0eac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171661
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2020-11-11 21:00:49 +00:00
Paul Berry 5f6d30da26 Add a verify_tests_test.dart to pkg/nnbd_migration.
This would have caught the need for
https://dart-review.googlesource.com/c/sdk/+/168462 and
https://dart-review.googlesource.com/c/sdk/+/171261.

Change-Id: I8da1f24cac5eb9df36ae1ca7299c0aeddbd80149
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171301
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-11 18:09:18 +00:00
Paul Berry da029c6ef3 Migration: try to help users who update their pubspec before migrating.
Fixes #44144.

Bug: https://github.com/dart-lang/sdk/issues/44144
Change-Id: I5db52426ba4e6a4cde803ae38fbc479cb8bbb862
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171624
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-11 18:03:52 +00:00
Paul Berry 05750310c9 Migration: rework fatal error reporting when pubspec cannot be parsed.
Previously, the user experience was an `UnimplementedError` with no
further information.  Now the user gets an error message telling them
how they need to update the pubspec, which I believe was the original
implementation intent.

Note that the field `_packageIsNNBD` has been removed.  Although the
comment for this field said it was tracking whether the package was
opted in to null safety, it actually had no effect (since the only
code path that would set it to `false` was after the
`UnimplementedError` and thus unreachable).

Change-Id: I3cef2f0a7203941b22e37e3ae1bee14806cfc9c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171621
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-11 17:49:02 +00:00
Sam Rawlins e0ef383234 Migrator: Add a summary_stats script
The script's Usage text has the best description.

Change-Id: I6baf747a13a7655e40bc0158cb40ad965fa6ee3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171422
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-11 16:56:42 +00:00
Paul Berry 50274ada87 Migration: add migration_summary_test.dart to test_all.dart.
Change-Id: I478ab5491fb3cbc32646d4ec3a76be838113bff1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171261
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-10 15:09:26 +00:00
Paul Berry 3e5f021579 Migration: add a test case for #44118.
Bug: https://github.com/dart-lang/sdk/issues/44118
Change-Id: I9c62d8d90240458c8609a74a2cd49b703da0fb29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171240
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-10 15:07:06 +00:00
Paul Berry 785c3258f6 Migration: remove deprecated code related to flag --skip-pub-outdated.
This flag was removed in
https://dart-review.googlesource.com/c/sdk/+/170561, but some of the
code related to it was deprecated and retained in order to avoid
breaking an internal client.  The internal client has now been
updated, so we no longer need the deprecated code.

Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I08cbb7a617a349c2a4debbe342643de817bc86b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-09 14:36:38 +00:00
Paul Berry f4001df118 Migration: include exports when checking that imports are migrated.
When I first implemented this I thought that checking exports wasn't
needed, since it's not allowed for a migrated library to re-export
symbols defined in an unmigtated library.  But it turns out we still
do need to include exports in the check, since there might be migrated
libraries that are only reachable in the transitive dependency graph
via an export, and we need to check that *those* libraries don't
import unmigrated code.

Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I280b4117373a3320fc1efe65abe24e344199754c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170840
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-09 13:16:34 +00:00
Paul Berry 9b4cbf46b8 Migration: clarify the "unmigrated dependencies" warning text.
The old phrasing was confusing because it was unclear which libraries
were being referred to.

Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: Id68f28fcd8ba5a80763e7bf86d6774289701d381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170841
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2020-11-08 17:00:17 +00:00
Devon Carew beb56d51f6 [pkg/nnbd_migration] remove a leading space from a message
Change-Id: Ida7bc63a1aa90e252b3bd65263f5d0a72e906c87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170747
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-07 22:02:26 +00:00
Paul Berry 7322bc027e Migration: replace pub outdated check with a check on transitive imports.
Instead of running `pub outdated` to see if the user's dependencies
have been migrated yet, the migration tool now examines all of the
transitive import dependencies of the user's code to see if they are
opted in to null safety.  This produces a more accurate result than
`pub outdated`, because it is able to ignore files in transitive
package dependencies that aren't reachable via imports
(e.g. references to `package:analyzer` brought in by `package:test`).

Fixes #44061.

Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I38465bcbf35e8552f0060b5d51c0f1cfc5d18c7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170561
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-11-05 23:05:51 +00:00
Sam Rawlins 40cfccda6f Migrator: Add a progress bar for explainMigration, which can take a long time.
This shows progress for work which happens after the migration suggestions have
been generated. This work is generating instrumentation details for the front
end.

When migrating the analyzer package, the progress indicated by this third
progress bar takes approximately the same time as generating suggestions (on
the same order of magnitude).

Fixes https://github.com/dart-lang/sdk/issues/44074

Change-Id: I0b40dd5e587b718bd1ef56d64f03929924cc430a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170563
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-05 22:10:51 +00:00
Paul Berry 9d3b932640 Migration: fix handling of .call tearoff on a function-typed expression.
Change-Id: I18b102ae83afdb051decfc26762619fb5746f73f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170364
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-05 19:18:54 +00:00
Sam Rawlins d01694d8aa Migrator: Do not overflow progress bar, or print warnings before ticks
Fixes https://github.com/dart-lang/sdk/issues/43752

Change-Id: I538b283b1cabe2b2212ada30317c14e76e182a06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170562
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-05 19:08:14 +00:00
Paul Berry e8c8e51139 Migration: opt in dependencies in migration unit tests
Early in the development of the migration tool, due to language
versioning support being incomplete, it didn't have a good way to
distinguish opted in from opted out code, so we had the convention
that any code not being migrated was opted in.  Now that we have
language versioning support, we need to explicitly opt that code in.

Without this change, we'll get bogus failures when we add logic to
detect unmigrated dependencies.

Bug: https://github.com/dart-lang/sdk/issues/44061
Change-Id: I12920ea75b8af2142a044314b89b76bb602897c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-05 18:16:57 +00:00
Paul Berry 221c697f31 Migration: fix handling of .call on a function-typed expression.
Change-Id: Ibdee57d455215cd974ea34c8aeab578bd801f87b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170361
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-04 18:28:17 +00:00
Paul Berry a44fe3f778 Migration: set SDK min constraint appropriately.
As discussed in
https://github.com/dart-lang/sdk/issues/44031#issuecomment-720967259,
we want to encourage users to publish null safe packages with an SDK
min constraint matching the SDK version that was used for the
migration, e.g. `2.12.0-18.0.beta`.  However, we also want to make
sure that users doing migration via internal, dev, or bleeding edge
builds publish their null safe packages don't wind up inadvertently
publishing packages that are un-resolvable with the latest beta SDK,
so if the user is on one of those versions, we'll set their SDK min
constraint to `2.12.0-0`.

And of course, once the feature ships to stable, we'll want users to
publish their null safe packages with an SDK min constraint matching
the version in which null safety shipped to stable.

This CL implements all of that functionality, and tests it by
overriding the `version` file in the analyzer's mock SDK.

Change-Id: Ib9ed97e691271da0ed391a6c1a5fe209aa959dce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-04 18:26:57 +00:00
Ivan Inozemtsev 4a46b6511e Revert "[pkg/dartdev] refactor the migrate command to subclass DartdevCommand"
This reverts commit c10be63d51.

Reason for revert: this creates a circular dependency between nnbd_migration and dartdev which is hard to support internally

Original change's description:
> [pkg/dartdev] refactor the migrate command to subclass DartdevCommand
>
> Change-Id: I60f91f14e066b3a173f45b3c988830d5b435f2ed
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170206
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Commit-Queue: Devon Carew <devoncarew@google.com>

TBR=devoncarew@google.com,bkonyi@google.com,sigurdm@google.com

Change-Id: I3ba4648ea7f879ea4a893df2a9d75581a6f48dec
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170348
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ivan Inozemtsev <iinozemtsev@google.com>
2020-11-04 17:22:59 +00:00
Devon Carew c10be63d51 [pkg/dartdev] refactor the migrate command to subclass DartdevCommand
Change-Id: I60f91f14e066b3a173f45b3c988830d5b435f2ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170206
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-04 16:28:47 +00:00
Paul Berry 92587baee5 Migration: fix "whereOrNull" transformation to handle complex targets.
Previously, when analyzing a call to an iterable method that could
potentially be transformed into an `OrNull` extension, such as:

  allMatches(str).firstWhere(..., orElse: () => null);

the migration tool would erroneously identify some subexpressions of
the call target (`str` in this example) as the argument supplied to
`orElse`, resulting in a crash.

This CL fixes the logic so that we use an `identical` check to verify
when we are looking at the argument to `orElse`.

Fixes #43956.

Bug: https://github.com/dart-lang/sdk/issues/43956
Change-Id: I2f4a0e81becf789cab5334d4926e014bda2772f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170162
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-03 22:48:17 +00:00
Paul Berry 4c59c39648 Migration: set SDK max constraint appropriately.
After further discussion, we've decided to reverse the decision from
https://dart-review.googlesource.com/c/sdk/+/169143 and have the
migration tool generate packages with a max SDK constraint of 3.0.0.
See
https://github.com/dart-lang/sdk/issues/44031#issuecomment-720967259.

Bug: https://github.com/dart-lang/sdk/issues/44031
Change-Id: I37b43dfb1f13dd0fe08ab81f4ac01bcc46016bc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170160
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-03 16:16:06 +00:00
Sam Rawlins 4097d3024a Migrator: Insert required keyword in correct position
Previously, migration might change:

m({@required @deprecated x}) {}

to

m({required @deprecated x}) {}

Which is illegal syntax.

Change-Id: Ib8397e9e22dbb951758a04c085c40905860a7cb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170026
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-11-02 23:40:25 +00:00
Paul Berry 3eb34ef646 Migration: programmatically generate package_config.json in unit tests.
Previously, we hard a hard-coded set that included all packages added
by unit tests, which created confusion when writing new unit tests.
Now, `addPackageFile` records a list of all packages and
`package_config.json` is automatically generated just before analysis
begins.

Change-Id: I3393c0266a54d051ffa7601e74753a75857635e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170024
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-02 19:55:39 +00:00
Sam Rawlins 416cfa7c41 Migrator: Add /*required*/ hints when meta not imported.
Currently the migrator can add `@required` from the preview, which will crash
the preview upon rerunning, if package:meta is not imported.

This change instead adds a /*required*/ hint when meta is not imported.

Additionally, /*required*/ is understood by the migrator just as if it were
`@required`.

Fixes https://github.com/dart-lang/sdk/issues/43751

Change-Id: I1ea532246b956feacedd179146372b13c65003df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169900
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-11-02 17:30:59 +00:00
Paul Berry 531ffd0e45 Migration: add repro for #44012
Bug: https://github.com/dart-lang/sdk/issues/44012
Change-Id: Iabddb6de213aa70feb42b273f0e48fc2b5fa582d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-11-02 14:43:29 +00:00
Sigurd Meldgaard ea7e27cfeb Roll dart_style 1.3.8+1 into the SDK.
There are no formatting changes in this release. The only change is the
fix for https://github.com/dart-lang/dart_style/issues/964.

Includes corresponding adaptations of dartdev/dart CLI.

Change-Id: I1c97f0b7009b98ae609b258401522453faa35c64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170083
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2020-11-02 13:42:19 +00:00
Paul Berry 0b0454f9e2 Migration: don't add experiment flag to analysis_options.yaml anymore.
Now that the flag is on by default, we no longer need to supply it
when migrating.

Bug: https://github.com/dart-lang/sdk/issues/43806
Change-Id: Ib2e4ae6cb0573cd2e28d61634c63a424aebfc60d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169145
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-29 20:05:10 +00:00
Paul Berry 53c31dbe22 Update migration tool to set pubspec/package_config appropriately for beta.
In the beta release, we plan to recommend that people set their
pubspec SDK constraints to `>=2.12.0-0 <2.12.0`, so this change
updates the migration tool to have that behavior.

In the second beta release we'll change switch the upper bound to
`<3.0.0`.

Change-Id: Ib90e893bebaebea968b19e7de663cbbbca570f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169143
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-29 20:05:10 +00:00
Paul Berry a44bbfbfb5 Revert "Migrator: Disable 'pub outdated' check temporarily"
This was a temporary measure to prevent user frustration with the
migration tool while null safety was not yet enabled by default.  With
null safety enabled by default, it's no longer needed.

This reverts commit f2b94295d3.

Fixes #41769.
Fixes #43774.

Bug: https://github.com/dart-lang/sdk/issues/43774
Change-Id: I4f7fbf0b980311d33428bc2a132b548a1c35c675
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169124
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-29 20:05:10 +00:00
Paul Berry 65eb643181 Migration: don't produce null!.
Instead, produce `null /*no valid migration*/`.  This should lead to
less user confusion (`null!` seems crazy, since obviously a null
literal will fail a `!` check).  Note that this will be a static
error, which will give the user a better chance of noticing and fixing
the problem.

Fixes #43972.

Bug: https://github.com/dart-lang/sdk/issues/43972
Change-Id: Ibf83b786dc486b14c001c17ca2ba902dafcb8a18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169600
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-29 18:34:36 +00:00
Paul Berry 33b7f1425e Migration: remove unreachable break statements
Change-Id: Id37990606eaa1caa3fe37b9df70b861fe7a00049
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169720
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-29 16:05:33 +00:00
Paul Berry 68fe2649f3 Migration: remove 2 pixel offset from CSS for .region.informative-region.
This was causing visual clutter by making informative regions offset
from regular code.  Worse yet, there was a "double vision" effect
because the top of the underlying non-offsetted text could sometimes
be seen behind the informative region overlay.

Change-Id: I206c74b3d91f305a21494b767ec27f396a8513b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-29 16:05:33 +00:00
Sam Rawlins 5ac5b710ee Migration --apply-changes implies --no-web-preview
* `--apply-changes` and no value passed for `web-preview`: assume
  `--no-web-preview`
* `--apply-changes` and `--web-preview` (each explicitly passed): error
* no value for `apply-changes` and no value passed for `web-preview`: assume
  `--web-preview`

Bug: https://github.com/dart-lang/sdk/issues/43866
Change-Id: I518f20f8095a6c9a11109fd9ae0f7c0e16050ddd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169521
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-29 13:15:23 +00:00
Devon Carew 80f0976e02 [pkg/nnbd_migration] mark package:nnbd_migration as not publishable
Change-Id: Iac9b8dd83ebd66bb9b2421584fd7fdd1ee364a73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169285
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-10-28 17:30:20 +00:00
Paul Berry 68c50f7f92 Migration: re-work test_informationalRegion_containsTraceLinks_separateDrive.
Previously, we were switching test paths to drive `D` at the start of
the test, after the `package_config.json` file had already been
generated to drive `C`; as a result, it didn't apply.  We will need
the `package_config.json` to apply when we flip the null safety flag
(so that the inputs to the migration tool are considered opted out
prior to migration).  This CL reworks the test so that the paths are
modified as part of test set-up, so `package_config.json` gets put in
the right place.

Fixes #43883.

Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I08f79ddb07d7a5ecf640370a32334a7ceb92ceff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169421
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-28 16:35:30 +00:00
Paul Berry 9181570513 Migration: Work around null reference exception with complex type parameters.
Change-Id: Ib3f081225f9ec7cb8714ca0aa789d4dea1a378db
Bug: https://github.com/dart-lang/sdk/issues/43945
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169252
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-28 14:01:57 +00:00
Paul Berry a777d2b798 Sort declarations in api_test.dart
Change-Id: Ia82546a1654ac11334fee380d358862385c17ed7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169253
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-28 14:01:57 +00:00
Devon Carew 297fb8606a Un-hide the dart migrate command from stable.
Bug: https://github.com/dart-lang/sdk/issues/43194
Change-Id: I04db8cc9f34e812ca2e6569edd86f37c1f4fcdd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169281
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-10-27 20:50:29 +00:00
Devon Carew dac61ff879 Remove a message for pre-nnbd sdks.
Bug: https://github.com/dart-lang/sdk/issues/43924
Change-Id: I900f03ebf67f9b4fe5bb9277555293d03295a34c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169241
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-10-27 20:27:57 +00:00
Paul Berry a666ac7ffa Migration: add preview info when changing iterable method calls.
With this change, the functionality of changing iterable method calls
such as `.firstWhere` into extension method calls such as
`.firstWhereOrNull` is working well enough that I think we can switch
it on.

We don't update the pubspec properly yet; that will be addressed in
follow-up CLs.

Change-Id: I758332e9752b12d399ecb5c70cf37bbc8da77d6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168988
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-25 18:57:35 +00:00
Paul Berry 5e2e2235ac Migration: handle inserted lines in UnitRenderer._computeRegionContent.
We don't want inserted lines to receive their own line number for two reasons:

- It makes the line numbers displayed by the migration preview fail to
  line up with the line numbers in the user's editor (since the lines
  haven't been added yet)

- It makes navigation links within the migration tool point to the
  wrong place, since these links are computed based on analysis of the
  pre-migration code.

So instead, we supply a line number string of `(new)` for inserted lines.

This required refactoring the algorithm for
`UnitRenderer._computeRegionContent` a bit.  Now, instead of trying to
accumulate the output HTML string all at once, we produce it one row
at a time, first accumulating the line text in a StringBuffer, and
then once the end of the line is reached, attaching the line number to
form a table row.  Then we join together all the rows into a table
when we're done.

Change-Id: Ie18632186ddd0f4f5f33d4da41b4943759699e1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168987
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-25 18:57:35 +00:00
Paul Berry 3ff14f19d3 Migration: include unimportant edits in UnitInfo.regions.
Previously UnitInfo.regions contained just information about edits
that we wanted to alert the user about; it didn't contain information
about unimportant edits like adjusting whitespace.

This caused problems when trying to make complex edits (like those
necessary to transform a `.firstWhere` call into a `.firstWhereOrNull`
call) because it interfered with UnitRenderer._computeRegionContent's
ability to properly compute file offsets.

So we now include all edits in UnitInfo.regions, and we distinguish
the unimportant ones by seeing that their `kind` and `explanation`
fields are `null`.

To ensure that important edits never wind up with `null` values for
these fields, we add assertions to the `NullabilityFixDescription`
constructor.

Change-Id: I89928150eb507524222d03acfae0b4770363443c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168985
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-25 18:57:35 +00:00
Paul Berry e20415403a Fix InfoBuilder._explainUnit to handle iterable method call renames.
The method we use to rename method calls to Iterable
(e.g. `firstWhere` -> `firstWhereOrNull`) causes a pair of consecutive
AtomicEdit objects to be generated: one to remove the old name
followed by one to add the new name.  This was causing
InfoBuilder._explainUnit to update its output offsets incorrectly,
because it waited until after processing all of the AtomicEdit objects
pointing to a single source offset before updating the output offset.
What it needs to do instead is update the output offset (in the
variable called `offset`) after processing every single AtomicEdit.

Change-Id: I8ad51e20d4021c62c45542cec7f0f54a9ff3cf26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-25 16:23:45 +00:00
Sam Rawlins 9598c7b108 Migrator: Prepare migration_cli_test for the flip CL.
This is a weird CL because it strives to keep tests passing before and after
the CL, when they include a lot of error-path tests with weird pubspec files
and package config files.

Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I55dd4b398f3b1b53b8f2df95b2dcf880104ec7b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168901
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-23 21:07:12 +00:00
Sam Rawlins 360363efc1 Migrator: opt all test files _out_ of null safety.
Well not quite all; migration_cli_test tests are a bit of a different
beast so I am going to tackle them separately. But this fixes over
1000 test failures, and should clean up test output for further
debugging of the flip CL.

Each test file needs to be in a package with a package config file
which spells out that it is _opted out_ of null safety.

Bug: https://github.com/dart-lang/sdk/issues/43883
Change-Id: I583f66119df57031fd80824111923e15e0f91782
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168900
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-23 21:07:04 +00:00
Paul Berry d751681647 Sort declarations in info_builder_test.dart
Change-Id: I00caa1860f93f2fb8cfcdf9fa571f9cd0cc880b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168980
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-23 20:01:22 +00:00
Paul Berry 7fde117f83 Sort declarations in migration_info.dart
Change-Id: I449c55bd570f60f4190be25a42e36d8c2b22a29e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168781
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-22 11:19:00 +00:00
Paul Berry f1843b0abe Add special case migration logic for iterator methods.
This logic allows us to migrate code like this:

    int firstEven(Iterable<int> values)
        => values.firstWhere((i) => i.isEven, orElse: () => null);

Into:

    import 'package:collection/collection.dart' show IterableExtension;

    int? firstEven(Iterable<int> values)
        => values.firstWhereOrNull((i) => i.isEven);

Rather than the default behavior, which would migrate it to:

    int? firsteven(Iterable<int?> values)
        => values.firstWhere((i) => i!.isEven, orElse: () => null);

(The new migration is far superior because it doesn't require the
input iterable to accept null).

This functionality is disabled at the moment, because:
- The changes it makes don't show up properly in the web preview.
- The pubspec is not yet properly updated.

I will address these issues in follow-up CLs and then enable the
feature.

Change-Id: I96f3b12d682c586631920b38406bad6aa3f4789e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168500
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-20 17:45:04 +00:00
Paul Berry 265ecc7488 Make test tolerant of changes to mock sdk
Change-Id: I5c2e6c964b666157977c66d8ad8a19ea41b09e58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-20 17:45:04 +00:00
Paul Berry 5898fefb92 Add missing invocation to test_all.dart
Change-Id: Ibcbe7f50555a66360b563ae3915d2567567dd025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168462
Reviewed-by: Janice Collins <jcollins@google.com>
2020-10-20 17:45:04 +00:00
Paul Berry 43166018a9 Nomenclature fix: migration diff output is not a summary.
The output the migration tool generates when the web preview is
disabled shows a complete diff of all changes the tool will make, so
it's really a misnomer to call it a "summary".

Change-Id: I8c7d9f9870bf8beffb62f1d10d36a65b66c32657
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168381
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-20 16:16:03 +00:00
Lasse Reichstein Holst Nielsen 92e52a1874 Remove direct dependencies on package:charcode from SDK.
Change-Id: I9ef36e8a6890a70baac6c18f0be2252dcf5453df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163941
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-20 13:07:53 +00:00
Paul Berry 98ccfc33df Sort declarations in pkg/nnbd_migration/test/api_test.dart
Change-Id: Ic4990bbb40fe571a5fcba3a9b03366266cd565db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167725
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-17 01:11:43 +00:00
Sam Rawlins 7c01226470 Fix navigation scrolling with big projects
Change-Id: Ie5fb3f79225354aef956e71467c0fe34b5e4cbc2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168122
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-16 21:56:52 +00:00
Sam Rawlins 33e7bae759 Migrator: Fix issue with map node under 'analyzer:'
Without this fix, the tool inserts an enable-experiment
section indented at the wrong spot:

analyzer:
  exclude:
    foo:
      bar: 1
    enable-experiment:
      - non-nullable

Change-Id: Ib6601733221e77a4028f3c0ac87b36c258db6ec0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168120
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-16 21:37:02 +00:00
Konstantin Shcheglov 3a97c9f602 Use legacy TypeProvider in AssignmentCheckerTest.
I'm looking into enabling NullSafetyUnderstandingFlag in the next
analyzer breaking change.

test_function_void_to_function_object() fails, and it seems that
the test class should use legacy TypeProvider, because `Object` is not
assignable to `void`, but `Object*` is.

Change-Id: Ib867e0eec7a387ed3ed1379a7ef34a58b16e54ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168125
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-16 21:10:03 +00:00
Sam Rawlins a23dbf7417 Migration: do not wrap navigation items
Change-Id: I6b3a2c41d4df9cc0f789d04f74cdddf79f7759d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168060
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-16 15:29:22 +00:00
Sam Rawlins 3191b45998 Edit analysis_options.yaml to enable the non-nullable experiment.
The file might be edited in one of a few ways, depending on what it contains.

Previously we read and edited pubspec, which is also YAML, so this
implementation borrows a lot of that, and renames several "pubspec" elements to
be "yaml" elements.

I try to cover in tests various odd existing analysis_options.yaml situations,
so that we try to never crash, or corrupt on weird input here.

Fixes https://github.com/dart-lang/sdk/issues/43806

Change-Id: Ifc57d583e98d798fd7bca748bbe4afef272edab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167862
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-16 12:58:32 +00:00
Paul Berry 6282572479 Remove deprecated method MigrationCli.addCoreOptions.
The internal code that was using this method has been updated to use
MigrationCli.options instead.

Change-Id: I46941b3a2b8dc65a66a3235052bc5c2110a9ab99
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167820
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-15 16:09:56 +00:00
Konstantin Shcheglov aad1a677c0 Deprecate GenericTypeAliasElement
See also https://dart-review.googlesource.com/c/sdk/+/166680

Change-Id: I6018f3bf5796dcc8ab059aab5b29d01e7336581b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167727
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-15 16:03:26 +00:00
Paul Berry acef33fd08 Avoid using http: URIs with relative paths in the migration tool.
Such URIs fail when the connection between the migration tool and the
user's web browser is proxied over https.

Fixes #43545.

Bug: https://github.com/dart-lang/sdk/issues/43545
Change-Id: Id457851d5c074ff707a2829c928401a766e15ece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167660
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-14 18:52:48 +00:00
Konstantin Shcheglov fbfc723de7 Use CompoundAssignmentExpression instead of LHS element/type.
This adds some technical debt in form of using writeOrReadElement in
clients, which can be paid incrementally by migrating these places to
handling assignment like expressions one by one. Doing it all in one
CL was too much. But now the underlaying AST resolution will be
sound.

In the next breaking change we will remove
setAssignmentBackwardCompatibility(), so stop setting elements/types
for assignment targets.

Change-Id: I11626876cfed25653edb0cc18544aba51cef5965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165622
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-14 18:45:08 +00:00
Devon Carew 7d994c106a Add a migration tool notice for TP2.
Change-Id: I3f882bc47c372e196186d6c9c539cc572d406f43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167620
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-10-14 17:30:17 +00:00
Paul Berry 63a406d78b Restore addCoreOptions functionality and create more robust replacement.
This CL unblocks the internal SDK roll by restoring the migration
tool's `MigrationCli.addCoreOptions` method (which is currently used
internally).  It also adds a replacement, `MigrationCli.options`,
which is more robust because it allows the client to choose which
options to include and which options to exclude.

Once this CL has rolled in, I'll update the internal code base to use
the new `MigrationCli.options` method and then remove the deprecated
`addCoreOptions` method.

Change-Id: I3ddbd935c3858c3302a2ad2b825b97df96249043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167443
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-14 00:27:47 +00:00
Paul Berry acf440fe42 Sort declarations in migration_cli.dart
Change-Id: I14c4b9b77eec3fef5a23f76877a8d291ca217198
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167423
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-10-14 00:27:47 +00:00
Paul Berry ad82b437f4 Prepare to publish package nnbd_migration version 0.1.1.
This will be the last published version, and is only being published
so that we can include a README entry indicating why the package is
not to be used.  After publishing, I will mark the package as
discontinued.

Change-Id: I95cb6d8d6ec41415edd2c8da300c165a0c4cfb93
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167444
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-13 22:53:04 +00:00
Sam Rawlins cddea627a7 Migrator: Accept 'late final' hint; same as 'late' hint
`late final` is not functionally different from `late`, as far
as the migrator is concerned; it is just an indication of late
in the face of missing initialization.

Fixes https://github.com/dart-lang/sdk/issues/41655

Change-Id: I1b0efd3de3b5c7064784ebd1e86c7d12436b1319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167203
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-13 19:41:58 +00:00
Sam Rawlins b9e8f6f09c Migrator: Use 2.10 as a lower bound for null safety to allow 2.11 dev versions
Fixes https://github.com/dart-lang/sdk/issues/43757

Change-Id: I989b1542d2c6746513cc88dcfeff995873536ac5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167400
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-13 19:41:18 +00:00
Sam Rawlins f2b94295d3 Migrator: Disable 'pub outdated' check temporarily
Bug: https://github.com/dart-lang/sdk/issues/43774
Change-Id: I128d0e24aa6b8c972f393d3e91aae418a44ed8ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167380
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-13 18:29:58 +00:00
Sam Rawlins 5c17af0843 Migrator: Refactor currentScrollPosition to be a function
Bug: https://github.com/dart-lang/sdk/issues/43546
Change-Id: Ie79b00b6471f4d5416e78fb6ca04e4c7f46d7231
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167381
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-10-13 17:54:08 +00:00
Paul Berry d6292f99c2 Add a notice to the nnbd_migration package README.
I plan to publish this on pub, and then mark the package as
discontinued.  Customers should invoke NNBD migration using the `dart
migrate` command.

Change-Id: Ia871e71258e3951ac7fd866e46ae97043a6fa93c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167364
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-13 16:29:08 +00:00
Sam Rawlins 284c78d338 Fix scrolling when clicking the "Add hint" buttons.
The fix is just to capture the scroll position when the button was clicked,
then rescroll to that pixel after reloading the file.

I also sorted migration.dart.

I also added comments while investigating migration.dart.

Fixes https://github.com/dart-lang/sdk/issues/43546

Change-Id: Iac0a7bf10a671fd6e6b5f02ee0609b7e36fc985a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167360
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-13 15:24:18 +00:00
Paul Berry 626c865a3e Support migration of partially migrated packages.
Rather than produce an error immediately upon encountering an
alredy-migrated library, we simply skip processing it; this causes its
elements to be added to the nullability graph on demand, just like for
already-migrated dependencies.

We still check for the possibility that *every* file in the user's
package has already been migrated, and issue an error if so (rather
than just doing nothing); this should help avoid user confusion if the
user tries to re-migrate an already-migrated package.

Bug: https://github.com/dart-lang/sdk/issues/42308
Change-Id: I8dd81a9c6ff2bb23ede91e89d1152bd7726dec32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167202
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-12 23:58:32 +00:00
Sam Rawlins ef30beda17 Migrator: Print less output in tests
Change-Id: I8add1a75de71a4b979399be821a4baa803bc0165
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167180
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-10-12 17:48:32 +00:00
Sam Rawlins a5455694d5 migrator: Bump opt-in null safety version
Fixes: https://github.com/dart-lang/sdk/issues/43757

Change-Id: Iabcb0ef088d94b29cad4663763a1a842a8c49dcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167160
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-10-12 17:23:22 +00:00
Devon Carew 07e2973f60 [pkg/nnbd_migration] some updates to the command line messaging for dart migrate
Change-Id: I780f7d6ec1e6985179f69ceb105519d5be838e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167120
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-10-12 15:53:32 +00:00
Paul Berry 2601fa6d78 Ensure that && and || expressions promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ib06449624de9320f5229957511ebaaee92c75ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166606
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 57932cfb4f Ensure that conditional expressions promote properly in unreachable code
Change-Id: I8680b81b44be789a047238b1e2d008ff240e59c2
Bug: https://github.com/dart-lang/sdk/issues/40009
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165405
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 18:16:52 +00:00
Paul Berry ed2f45d56d Ensure that if statements promote properly in unreachable code
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I04a5af558bb70b861d92b5379a8fb84489d5c9f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165402
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 15:32:25 +00:00
Paul Berry e933e91aaa Reland "Flow analysis: promote to non-nullable on initialization"
This is a reland of 6a1c54ec30

Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes #43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Bug: https://github.com/dart-lang/sdk/issues/43099
Change-Id: I7530bb0f7c24674a7b500558b89d50b35e045aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166305
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-07 13:14:55 +00:00
Clement Skau b4f49dc255 Revert "Flow analysis: promote to non-nullable on initialization"
This reverts commit 6a1c54ec30.

Reason for revert: Triggers test failure:
https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-debug-x64/8247

Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes #43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

TBR=paulberry@google.com,scheglov@google.com,rnystrom@google.com,johnniwinther@google.com

Change-Id: I8549b48a734f527194ce11d82235b9d5c6e58185
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165564
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-10-01 08:41:15 +00:00
Paul Berry 6a1c54ec30 Flow analysis: promote to non-nullable on initialization
When flow analysis encounters a variable declaration of the form `T? x
= expr;`, if the type of `expr` is `T`, then the variable is
immediately promoted to type `T`.

Fixes #43099.

Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-01 01:15:31 +00:00
Konstantin Shcheglov 8de1bc0a07 Stop using getReadType() in nnbd_migration.
The packages 'analyzer' and 'nnbd_migration' tightly depend on each
other via MigrationResolutionHooks. I will publish analyzer 0.40.4
shortly after this CL lands.

Change-Id: I6f5e51f88e0020a1674ffb251712658e896170e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-29 17:18:25 +00:00
Konstantin Shcheglov e3fcb1a646 Remove unnecessary convertPath() invocations.
Change-Id: I57d0d2204df02bd9a5fc97986347ac0218442d39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164722
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-26 18:25:00 +00:00
Konstantin Shcheglov f9e6e38b21 Straighten up invocation of an Object method on dynamic.
Fixes https://github.com/dart-lang/sdk/issues/39609

Change-Id: I9b98d9bff8d4e9b75ab7625323f62eb6b6701a94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164256
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-25 16:46:04 +00:00
Konstantin Shcheglov d219bde703 Enforce await_only_futures and fix violations (in more packages).
Change-Id: I1812f7721915178e42956f988b9276bf8db0bfaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164281
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-24 16:58:50 +00:00
Paul Berry f860868740 Flow analysis: remove old "promotable via initialization" logic.
This logic was removed from the spec in
b70bb3f906.

Only a few places in the SDK itself were relying on this promotion
logic; I've fixed those places by adding explicit types.

Change-Id: Iaeaebe8dd5ab3e848699bc8ebc64a1ae80c1027a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163681
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-22 12:22:13 +00:00
John Ryan 90ff5d0af6 Add favicon to nnbd_migration tool
Uses the existing dart_192.png image.

Alternatively this could have been done using a favicon.ico file but
that would have required more boilerplate, so I went with a simpler
approach.

fixes #43438
https://github.com/dart-lang/sdk/issues/43438

Change-Id: I91e0c28a2c0a28db58dbf5189aae4d099c19b23c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163500
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: John Ryan <ryjohn@google.com>
2020-09-21 17:51:47 +00:00
Konstantin Shcheglov 9ef060886e Fix lints in nnbd_migration.
Change-Id: I57a8de216709beb1c65877bb228e1a0365ac6976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-18 18:32:06 +00:00
Sam Rawlins 475ffb96c0 Migrator: Use pedantic 1.9.0
Change-Id: Ia53e84ac6b2f3ab0679710c14453fd65c8f9c00d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163161
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-09-17 20:52:43 +00:00
Paul Berry a3c10e3653 Migration: clear regions at the top of InfoBuilder._explainUnit.
There are certain rare conditions involving generated code in a bazel
workspace that can cause a source file to get processed more than once
by the migration tool (sometimes with a correct URI, sometimes with an
incorrect URI that corresponds to a file path in the `bazel-out`
directory).  For the most part the migration tool is tolerant of this
situation, but it can cause InfoBuilder._explainUnit to get called
twice for the same unit.  To avoid this creating user-visible
problems, we need to ensure that any regions left over from the
previous invocation of InfoBuilder._explainUnit are cleared out before
we re-populate the region list.

Bug: https://b.corp.google.com/issues/168295421
Change-Id: I18936b03261c30b8c9062b4a568e1a1e094ec867
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162800
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-09-14 23:58:58 +00:00
Sam Rawlins 151292572c Migrator: Check analysis results before re-running.
* Refactor MigrationCliRunner, mostly simplification.
* Add AnalysisResult class to track analysis errors.
* MigrationState now contains an AnalysisResult, and the previewUrls.
* Add logic in the UI to display analysis results.
* Add logic to the backend to display analysis results.


Fixes https://github.com/dart-lang/sdk/issues/41712
Fixes https://github.com/dart-lang/sdk/issues/43138

Change-Id: I3304467955cfa81820f0010d32e17931b3c68b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162400
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-09-10 20:55:14 +00:00
Sam Rawlins 8035d5a0a7 Migrator: Switch styles for un-changed NN type and inserted "?", "!", etc.
Fixes https://github.com/dart-lang/sdk/issues/43125

Some screens:

Old: https://screenshot.googleplex.com/6dqJeWEvX2pYSi4
New w/o position change: https://screenshot.googleplex.com/8HorAjqMw2tMshk
New + bold font (not included in CL; just for reference): https://screenshot.googleplex.com/3N9cMr4RijXv5sM
New w/ position change (included in CL): https://screenshot.googleplex.com/9TfLKpHCCZkzLXX

Change-Id: Ib8aaf3ae56e645beaa01b2cf9e78db68544441b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162242
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-10 18:57:58 +00:00
Paul Berry a4b2047d9d Reland "Flow analysis changes to fix mixed-mode unsoundness loophole."
This is a reland of d833f2f65c

Original change's description:
> Flow analysis changes to fix mixed-mode unsoundness loophole.
> 
> This is the flow analysis portion of the fix to
> https://github.com/dart-lang/language/issues/1143.  Follow-up changes
> will be needed in the CFE and/or backends to ensure that exceptions
> are thrown under appropriate circumstances.
> 
> This CL also makes some improvements to flow analysis's reachability
> analysis so that it accounts for nullability of the target when
> analyzing the reachability of `??=` and `?.`.  Hopefully these
> improvements should make the fix to
> https://github.com/dart-lang/language/issues/1143 clearer and more
> consistent.
> 
> Change-Id: I5fa5c070f13fd57ac4c2fb87f2d67588861594b0
> Bug: https://github.com/dart-lang/language/issues/1143
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160440
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

Bug: https://github.com/dart-lang/language/issues/1143
Change-Id: If9c45649c1e9f4b19f7c282e7a1c4c956a7bc17f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161622
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-09-03 01:01:43 +00:00
Konstantin Shcheglov 1b26394a63 Upgrade nnbd_migration to analyzer 0.40.1, switch to VariableElement.hasInitializer
Change-Id: Iddcc04a8b86dc9e24df003fd8bbd090f025aeef6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161443
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-02 19:46:22 +00:00
Mike Fairhurst 30cfb228c0 [nnbd_migration] Remove unused dart:async imports
Change-Id: Ie370dc43312bc872712e1cf811eb7194a30c9945
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161468
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-02 17:30:32 +00:00
Paul Berry ab16d79af9 Revert "Flow analysis changes to fix mixed-mode unsoundness loophole."
This reverts commit d833f2f65c.

Reason for revert: Broke build, e.g. https://ci.chromium.org/p/dart/builders/ci/dart-sdk-mac/12688

Original change's description:
> Flow analysis changes to fix mixed-mode unsoundness loophole.
> 
> This is the flow analysis portion of the fix to
> https://github.com/dart-lang/language/issues/1143.  Follow-up changes
> will be needed in the CFE and/or backends to ensure that exceptions
> are thrown under appropriate circumstances.
> 
> This CL also makes some improvements to flow analysis's reachability
> analysis so that it accounts for nullability of the target when
> analyzing the reachability of `??=` and `?.`.  Hopefully these
> improvements should make the fix to
> https://github.com/dart-lang/language/issues/1143 clearer and more
> consistent.
> 
> Change-Id: I5fa5c070f13fd57ac4c2fb87f2d67588861594b0
> Bug: https://github.com/dart-lang/language/issues/1143
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160440
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,scheglov@google.com,johnniwinther@google.com

Change-Id: If1215b19975e0958d612dd69767088095d853879
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/language/issues/1143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161580
Reviewed-by: Paul Berry <paulberry@google.com>
2020-09-02 15:02:46 +00:00
Paul Berry d833f2f65c Flow analysis changes to fix mixed-mode unsoundness loophole.
This is the flow analysis portion of the fix to
https://github.com/dart-lang/language/issues/1143.  Follow-up changes
will be needed in the CFE and/or backends to ensure that exceptions
are thrown under appropriate circumstances.

This CL also makes some improvements to flow analysis's reachability
analysis so that it accounts for nullability of the target when
analyzing the reachability of `??=` and `?.`.  Hopefully these
improvements should make the fix to
https://github.com/dart-lang/language/issues/1143 clearer and more
consistent.

Change-Id: I5fa5c070f13fd57ac4c2fb87f2d67588861594b0
Bug: https://github.com/dart-lang/language/issues/1143
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-02 14:27:52 +00:00
Paul Berry e8201aa761 Migration: fix a crash when downcasting to the Null type.
Change-Id: I905e5fe658989969fe72953485f86de1689c5b51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-31 20:38:48 +00:00
Paul Berry a832289de6 Migration: fix handling of late hints followed by an underscore.
Change-Id: If22d3b398c53912d0de8f5a9977c13411884840c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161142
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-31 20:38:29 +00:00
Devon Carew f81dadfa32 [dartdev] update the help text for dartdev and related commands
Change-Id: Ia7139b109872575e58fa8f1cbc4aa72bef44bee5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161020
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-08-31 20:17:48 +00:00
Sam Rawlins 4e7848d17a Migrator: Fix windows path failure.
Fixes https://github.com/dart-lang/sdk/issues/43178

Change-Id: I9b41c7bf3f317abfe8f06b37a40ebd9a3d63a813
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160960
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-31 18:16:28 +00:00
Sam Rawlins 6f0e28b0c8 Fix #43178 by calculating relative path before doing the URI mapping.
Change-Id: I76c3a62d393537da1dbc73cacb9fedfc66f3d2d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160443
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-27 20:00:27 +00:00
Paul Berry 9046c6e1db Migration: separate core command line options from others.
This allows the core options to be re-used by other tools.

Change-Id: Iea9c18bf4568280dbf2a93ba43656b266226bcf5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160341
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-27 03:13:16 +00:00
Paul Berry 2cb426f9fc Fix context type for compound operators.
This is partially in support of the new numeric typing rules for null
safety, however it turned out that the anaylzer wasn't setting the
context type properly even in legacy code.  I've fixed both legacy and
null safe behaviors and included tests to cover both.

Fixes #39642.

Bug: https://github.com/dart-lang/sdk/issues/39642
Change-Id: Ie4d0936d335b1f750eae4febe76f2b8879c228b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159965
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-26 18:21:05 +00:00
Devon Carew 504195907b [dartdev] don't expose the 'dart migrate' command on the stable channel
Change-Id: I95d5d9dd74e488c749f17fd358d20188de32866c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160184
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-08-26 17:42:55 +00:00
Konstantin Shcheglov 0cc487a00e Stop using package:analyzer/analyzer.dart in migration test.
R=paulberry@google.com

Change-Id: I47ac999b0912d14f17a16da88a48816f65b4c5f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159973
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-25 02:20:17 +00:00
Sam Rawlins 20261e77af Migrator: Include the auth token in various links:
* Navigation links on the left
* target links in source
* "Proposed edit" links

Fixes https://github.com/dart-lang/sdk/issues/43135

Change-Id: I8ee8899286faadfda20dcf02aa409e118e227bcb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159970
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-24 23:47:27 +00:00
Paul Berry 08dd4b1faa Null-safe numbers: implement static typing rules, hook up for binary operators.
Future CLs will hook up the static typing rules for method calls
(`clamp` and `remainder`) and will implement the rules for contexts.

Bug: https://github.com/dart-lang/sdk/issues/42629
Change-Id: Iccfb1fa1ac9aff6c0832d65e4835b5b9bd51a804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158501
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-24 15:34:33 +00:00
Sam Rawlins e7c79ae9ae Migrator: fix issue with applying hint, then navigating.
Bug: https://github.com/dart-lang/sdk/issues/42636
Change-Id: I2bda4f91eb6da738b2b2a9c0f0a17d1a71b027cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159780
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-08-24 13:32:04 +00:00
Sam Rawlins b1094db98b Fix Migrator tool generation on Windows
Bug: https://github.com/dart-lang/sdk/issues/42636#issuecomment-678289547
Change-Id: I426bf87cfc29f19fdabbc5ce7692dd98e25ba33c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159760
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-08-24 13:31:44 +00:00
Paul Berry 194be0b23f During migration, if a getter is nullable, make the setter nullable too.
This is necessary because whatever type is returned by the getter must
be accepted by the setter.

Bug: https://github.com/dart-lang/sdk/issues/43119
Change-Id: I5a43ec3750328081c39c26ba6fb937a9be068eb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159644
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-21 20:03:00 +00:00
Paul Berry e8577913eb Sort declarations in edge_origin.dart
Change-Id: I8a410be295191abbaa332b0d626abd5320d32fb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159585
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-21 16:58:20 +00:00
Devon Carew c04ef0ba96 [dartdev] update the link to the 'dart migrate' migration docs
Change-Id: Ide264b97d4dd192a015b6b53b63521452dd64322
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159303
Reviewed-by: Jaime Wren <jwren@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-08-19 20:18:07 +00:00
Konstantin Shcheglov 2b7fc8f134 Update FeatureSet to the new rules.
Bug: https://github.com/dart-lang/sdk/issues/43032
Change-Id: I6c7d7dc56fd0d4edcc3c6f6cc6fb0422316b8f4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159187
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 18:27:37 +00:00
Devon Carew 1eed2dcc2a update the pubspec file for pkg/nnbd_migration
Change-Id: I8ad96626dff34875394d4c5111549ae430de4ce5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159145
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 15:14:22 +00:00
Konstantin Shcheglov a51f1747e0 Prepare to publish analyzer 0.40.0 and _fe_analyzer_shared 8.0.0.
Change-Id: I126207dcc47885565a3a6d7002ff15ad3cc493c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 15:12:10 +00:00
Konstantin Shcheglov 2bf61f4936 Don't call getFileSync() in tests.
I see no reason why this would be useful.

But it might be harmful.
When we create file1 that imports file2, and call getFileSync(file1),
the analyzer will read both file1 and file2 while building the
file graph. So, when we then create file2, it will not be read unless
we call changeFile(file2). And we don't.

Actually, if we want to simulate how migration works, we should first
create all files, and then migrate them.

R=paulberry@google.com

Change-Id: I22ff994d346c4ad985e5d06a34e9fd854d451757
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-18 14:58:30 +00:00
Paul Berry 5642366611 Null safe numbers: plumb element through to refineBinaryExpressionType.
The new rules for null-safe number promotion apply to both operators
and ordinary method calls, so I'll be implementing them in terms of
MethodElement.name rather than an operator TokenType.  To make this
possible, we need to pass the method element to
TypeSystem.refineBinaryExpressionType.

I'm doing this as a separate CL from the main implementation so that I
can verify that it doesn't introduce backward compatibility issues.

Bug: https://github.com/dart-lang/sdk/issues/42629
Change-Id: I6be9086553ee0ea9994994c903880fe9bb4477fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158480
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-17 23:17:55 +00:00
Paul Berry e403e6ae77 Flow analysis: rework handling of equality tests.
The new logic classifies the LHS and RHS of the equality check as
either null, non-nullable, or potentially nullable, and then either
promotes, treats the expression as equivalent to a boolean, or does
nothing, as appropriate.

This means, for example, that a comparison between a non-nullable
value and `null` is now known to evaluate to `true` for reachability
analysis.

Note: as part of this change, it was tempting to trigger promotion
whenever a varialbe is equality compared to an expression of type
`Null`, but this would be unsound (consider `(int? x) => x == (x =
null) ? true : x.isEven`).  So we still only promote when the variable
is compared to a literal `null`.

Fixes #41985.

There's a corresponding spec change out for review:
https://github.com/dart-lang/language/pull/1134

Change-Id: Id7f1d4eaa3b0fa57124445bb8352eef32c304feb
Bug: https://github.com/dart-lang/sdk/issues/41985
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155926
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-08-14 12:16:36 +00:00
Konstantin Shcheglov 302ad7ab2c Replace isNonNullableByDefaultInternal flag in LibraryElementImpl with FeatureSet.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I4fdb464df5f70ae93ccff5f06d8c99d34d3f8e31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158500
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-13 17:27:04 +00:00
Devon Carew 31361ff444 [deps] bring cli_util 0.2.0 into the repo; update the analyzer dep
Change-Id: I705d500a745b5ca972bdc49314b39ee9357989f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157541
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-06 17:27:29 +00:00
Paul Berry 2225b6f472 Migration: fix handling of async functions that return FutureOr.
Change-Id: I613d0bfd8340062bb78b20a8fd035d24a4ccdf8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155543
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-07-23 13:27:28 +00:00
Paul Berry f907e561c9 Migration: never produce a type of the form FutureOr<T?>?.
`FutureOr<T?>` is already nullable, because `FutureOr<T?>` ==
`FutureOr<T | Null>` == `Future<T | Null> | T | Null`.  So the second
`?` is redundant.

Also fix a bug where we were treating a `Null` type as `Never` if we
couldn't find a reason to require it to be nullable; this was
inconsistent with how the FixBuilder was handling `Null` (which is to
leave it unchanged).

Change-Id: I5e0e4b7fb449988d8ff0dd87a2b4c3da4a6ecebb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155506
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-23 13:24:48 +00:00
Paul Berry ded9b3ce3f Flow analysis: consider promotion to Never to be unreachable.
Fixes #41981.

Bug: https://github.com/dart-lang/sdk/issues/41981
Change-Id: Id2ce176c703cb3346d4bd7471b10ecac9e3b9907
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154624
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-20 16:17:57 +00:00
Paul Berry 0fee7d6a14 Migration: fix handling of class C<T extends C<T>>
Fixes #42732.

Bug: https://github.com/dart-lang/sdk/issues/42732
Change-Id: Ifd3e294abceb0478a1f945ff8bd305cebbd043ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154847
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-20 16:01:47 +00:00
Sam Rawlins d90daf9154 Analyzer: Report unused optional parameters of private functions
Fixes https://github.com/dart-lang/sdk/issues/29731

This change produces UNUSED_ELEMENT hints for optional parameters
for which no arguments are ever explicitly given, under the following
circumstances:

* parameter is for a constructor, method, or top-level function which
  is not accessible outside the library,
* function is never torn-off (all bets are off once its been torn off),
* method does not override a method in which the matching parameter is
  required,
* method does not override a method with a matching paramter, in which
  an argument is given for the matching parameter.

Change-Id: Idabf051f55140b62a440dc63ca0234f22598a5e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152730
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-17 19:30:27 +00:00
Paul Berry a3d3777094 Migration: add a hook invoked after changes are applied.
Change-Id: I97b5f132ab24887d6274fcaef96fadeac85de6da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154621
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-16 00:14:02 +00:00
Paul Berry c71d40f70b Migration: allow clients to use CommandLineOptions.
Previously this class was marked `@visibleForTesting`, but we need
clients to be able to create instances of this class in order to drive
the migration process.

Change-Id: Ibb8a4cda342942dcb15e6fd7625387d246b41f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153800
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-09 15:21:52 +00:00
Michael Thomsen 897706edbd Remove unrecommended flag from output:
The current output indirectly advertizes premature out-of-order migration,
which would be bad if it happened widely.

We can keep the flag, but should not advertize it.

Change-Id: I8bde10489cef8e1104e2e5216e03aed61bc95ba0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153612
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2020-07-09 01:19:53 +00:00
Konstantin Shcheglov a1f510080d Use analyzer 0.39.12 in nnbd_migration.
So, we can use package:analyzer/src/dart/element/type_system.dart
instead of src/generated/... library.

R=brianwilkerson@google.com, paulberry@google.com

Change-Id: Ic804cd29429bf8a85d25e21f77292a6816a3ede7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153363
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-07-07 20:59:50 +00:00
Konstantin Shcheglov 9cfdc02e58 Stop depending on exports from generated/resolver.dart
We cannot remove them completely just yet, there are users in google3.
But this CL will allow experimenting internally to track these users
and update them similarly.

R=brianwilkerson@google.com, devoncarew@google.com

Change-Id: Ic588b2873f9d5202783c8991f58e86bab28bd47e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153240
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-07-03 15:55:41 +00:00
Paul Berry b514f45ac7 Migration: allow tests to override preview server's use of ipv4.
This is necessary for some Google internal testing environments that
are ipv6-only.

Change-Id: I1385786bd0f9614fabcf5730d96a0d6018c6401e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153063
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-07-01 21:26:04 +00:00
Paul Berry 22da8934ac Migration: properly handle extension override syntax.
There were two problems:

- EdgeBuilder wasn't handling the extension override syntax at all,
  causing a crash.

- FixBuilder wasn't overriding the behavior of
  ExtensionElement.extendedType, causing a star type to be used as a
  context for the target expression; this prevented the fix builder
  from realizing when it needed to insert `!` after the target
  expression.

Fixes #42455.

Bug: https://github.com/dart-lang/sdk/issues/42455
Change-Id: I5a9f66f83db73a796e72708022faefd527667e32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-30 16:00:47 +00:00
Paul Berry 11aaa12d0a Migration: revert informative region height changes.
These height changes caused the overlay containing highlighted regions
to lose alignment with the underlying text, making the preview output
nearly unreadable for files with a lot of informative regions.

Change-Id: Ie6d0e9e58d28bc63dea5ae1e0a6a630f00c814ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152729
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-27 20:44:11 +00:00
Sam Rawlins d022d4c9e1 Migrator: Fix if-null promotion with GLB
Fixes https://github.com/dart-lang/sdk/issues/42375

EdgeBuilder wishes to do its own GLB type-joining, as does FlowAnalysis.
When FlowAnalysis pushes a promotion in ifNullExpression_rightBegin,
and then in write, and then pops those two promotions to join them in
ifNullExpression_end, EdgeBuilder is not given a chance to make its
own GLB node. Instead promotion never happens: the DecoratedType which
is the variable's type is promoted to non-nullable, for the left side.
The DecoratedType for the right side expression is not considered
non-nullable, so the FlowAnalysis.join will always fail to promote.

TypeOperations.adjustPromotedTypes solves this. It is a no-op in all
implementations except in EdgeBuilder.

Additionally FlowAnalysis.write's promotion fails for the same reason:
the only type of interest is the declared type made non-nullable, and
no matter what, the writtenType is not a subtype of this.

TypeOperations.forcePromotion solves this. It is a no-op in all
implementations except EdgeBuilder.

Change-Id: Iba6b9a69583af8fe1aa23124c7d66047acfff495
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152104
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-25 21:09:12 +00:00
Nate Bosch 14aa6cd87a Remove a debug print statement
Change-Id: Ic2b595fe4201ec83ee374e2208bed7cba1d8be67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152201
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-23 20:49:23 +00:00
Sam Rawlins 448016e811 Migrator: add --preview-hostname option
Fixes https://github.com/dart-lang/sdk/issues/41084

Change-Id: I35068ecf2cf0cec5cac418146149d0e0705dc05d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151666
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-23 18:50:53 +00:00
Brian Wilkerson ded14919b2 Clean up some hints in the migration engine package
Change-Id: I351884a7246b1f786b7e4fb468110dacfa2d5e4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152106
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-06-23 18:08:43 +00:00
John Ryan 2d22e4ca26 Set informative-region text color.
Text is now white on a light-blue background.

Change-Id: Iac613c49fc8db6241ba013341fb29045f89048e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152042
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: John Ryan <ryjohn@google.com>
2020-06-23 00:21:26 +00:00
John Ryan 3c85ade7f9 Migration tool UI improvements
- Update header text and buttons
- Add Roboto font
- Add Roboto Mono font
- Add Material icons font
- Update color scheme
- Move help button to header
- Change "Report a problem" button to "Send Feedback"
- Update button colors

Change-Id: Ia4d8b71ae8ec7a7c04ab8c238ffb0499becc9620
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151663
Commit-Queue: John Ryan <ryjohn@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-22 18:19:16 +00:00
Mike Fairhurst ea7e6f29bf [nnbd_migration] Fix #42374: mark types as non-null for assert(is T)
Fixed: 42374
Change-Id: I009cba3d0a3d16e57aec24c62fbb3e0cbfa03c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151925
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-06-22 18:08:36 +00:00
Brian Wilkerson ab73158758 Fix the windows bot and update MockSdk
Fixing the test that's causing the Windows bot to fail required updating
the MockSdk, which cause a lot of other changes. I would have done this
in two separate CLs if I'd known how big this was going to get, but I'm
hoping it isn't too big.

Change-Id: Idee56bab5e73a78ab7857e81177090493aa08b40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151874
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-06-22 14:34:25 +00:00
Paul Berry 717efd357f Migration: do not add ? after the Null type
Fixes #42322.

Change-Id: I4c26985da520e024b8a6c335834dd0fc2a41d59d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151561
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-17 21:29:51 +00:00
Paul Berry 7cd5e1ecbd Sort declarations in fix_builder.dart
Change-Id: I914e6fb43f17d8b2c2f01ec83a13c0bb9ef1e729
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151580
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-17 21:29:51 +00:00
John Ryan 8fe9dac0c8 add Dart logo to null safety migration tool
Change-Id: Ie9cd580fad0e596f1653e3a87cde75e133d1fe2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151360
Commit-Queue: John Ryan <ryjohn@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-17 20:17:21 +00:00
Paul Berry 82750c58f7 Update toList in analyzer's mock SDK
Fixes #42327.

Change-Id: Iecab55d0c97d439de02ac63ba53a0511532c773f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-17 17:20:57 +00:00
Sam Rawlins 8fcb9e4b0e Migrator: draw a hard edge when marking an AsExpression non-nullable
Fixes https://github.com/dart-lang/sdk/issues/41397

Change-Id: I03307f297954f97911ed501240df17e48ef2dfc8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151480
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-17 14:38:24 +00:00
Paul Berry 0b12c1d775 Migration: fix crash when there is an extension in code not being migrated
Change-Id: Ie7d4daf827f7803ea4001a26e06aa58577b9d49a
Bug: https://buganizer.corp.google.com/issues/158730342
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151443
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-17 14:03:44 +00:00
Leaf Petersen d44457f79d [Core Libraries] Eliminate the fork in the core libraries.
Move the nnbd core libraries from sdk_nnbd to sdk, and updates
references in build files and elsewhere accordingly.

Change-Id: I09760fe1e006657aacdfe80f3b22fdf6f7e30a9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151121
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-06-16 23:37:36 +00:00
Paul Berry ed9112e862 Sort declarations in api_test.dart
Change-Id: Ibe2b078f6a38a79d304ad81b1625c72a65fe53c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151320
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-16 21:10:11 +00:00
Paul Berry a9bb706ce2 Migration: allow the client to specify which files to analyze/migrate.
Change-Id: Ie49f003640342a8c0d26b4f509a9268200955dda
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151302
Reviewed-by: Janice Collins <jcollins@google.com>
2020-06-16 21:10:11 +00:00
Mike Fairhurst e11eb2cd08 [nnbd_migration] Fix #42263, tool inserting ! on toString/hashCode
Fixed: 42263
Change-Id: Ia4c6d3543bc7628c76b85d986b9709de58925884
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151441
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-16 20:21:31 +00:00
Paul Berry d1638508c1 Migration: streamline behavior injection in migration_cli_test.dart.
We now store both environmentVariables and injectArtificialException
in the _MigrationCliTestBase class, and refer to them wherever they
are needed, so we reduce the amount of plumbing we need to do.

In a follow up CL I'll be adding more behavior injection using the
same technique.

Change-Id: Ib736373f7a92a46922964d3c5c59d35bf72d618a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151300
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-16 17:52:10 +00:00
Sam Rawlins efcb8f9213 Migrator: Do not connect return values to return types on generators
Fixes https://github.com/dart-lang/sdk/issues/42299

Change-Id: I07b3955907efa3007ec146f4cb4170b117b58dcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151328
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-16 14:08:54 +00:00
Sam Rawlins 61184814e2 Migrator: use dart pub to check outdated
Fixes #42343

This also prevents a crash if the binary-to-execute could not be found.

Change-Id: I19dd9f6dcbb41a5c8b4ef2a04a87c1fc83429120
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151327
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-16 14:08:04 +00:00
Sam Rawlins 459255ab09 Migrator: Fix navigating to top-of-file
There is logic to navigate to the top of a newly-loaded page. It
broke with a visual redesign, in which the title of a page is always
sitting at the top of the screen. The new logic will scroll the page
to the first line of source text.

Change-Id: I685d1fb96c6ca1789f114871acd2bb8148e6ae7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151032
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-15 18:15:12 +00:00
Paul Berry 2fbe5c1f54 Migration: Make the three migration phases explicit in NonNullableFix API.
Previously the API was general, exposing a `numPhases` integer, and
providing a generic processing function with a `phase` argument.  This
was necessary back when migration was built into DartFix (because
different kinds of fixes had different numbers of phases), but now
that migration is a separate tool, it gets in the way because it makes
it difficult for the caller to have different behaviors in different
phases.

This is a prerequisite for making it possible to have some files
analyzed but not finalized (which is in turn necessary for handling
generated files).

Change-Id: I5993808eb3dace21d8b6cb9c5308f94a3b1f898e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-15 15:26:48 +00:00
Paul Berry 9f8776f4a9 Migration: split out a MigrationCliRunner API from MigrationCli.
This API can be used by tools that wish to perform migration but want
to provide their own command-line argument parsing.

Change-Id: Ic54e993139c803ded5ac39229ae84980db12184e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151080
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-15 15:26:48 +00:00
Paul Berry a7c93201e4 Migration: rework how MigrationCli.run() reports an exit code.
Previously, MigrationCli.run() would always return, but it would set
MigrationCli.exitCode to indicate whether an error occurred.  This
made it necessary to thread a lot of tricky logic around to ensure
that we would exit quickly if an error occurred.  This CL switches to
using an exception, so we get the same effect automatically.

Change-Id: I2b885092dec551700900b118ec3d9acd2f3649d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150760
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-15 15:26:48 +00:00
Sam Rawlins 3dc27a55fa Migrator: Add a failing test for #42327
Bug: https://github.com/dart-lang/sdk/issues/42327
Change-Id: I5ac4dbaf95efdc7b54ea4009b78187e519cac92d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151094
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-13 14:31:15 +00:00
Sam Rawlins 213f805294 Migrator: Bump highlight.js to 10.1.0
Fixes https://github.com/dart-lang/sdk/issues/41885

Change-Id: I2c19a36f0eb46e2941ca143c23e2b0be938b7d96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151089
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-12 22:17:12 +00:00
Sam Rawlins b907f9928f Migrator: Begin flow analysis on top-level annotations
Fixes https://github.com/dart-lang/sdk/issues/42295

Change-Id: I9d224b5c8a3fa5d57f17e434a9e6dfbcebc14781
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151026
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-12 22:01:32 +00:00
Paul Berry b1442a1f9a Remove unused import
Change-Id: I6d25e5ea3f1fdf320ec85d5f405789e6e8c2ddf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151084
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-12 20:25:39 +00:00
Paul Berry 43131b575e Migration: fix crashes with extension Foo<T extends ...> on T
Change-Id: I3a8f1be4f52a6a49bb57ab032fef668482f5acf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151002
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-12 18:21:15 +00:00
Devon Carew c607eb9637 [nnbd_migration] address an issue with the progress text written to stdout
Change-Id: I8bd4b4a291d1d64b48752c06f2ec7784e5bac819
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151040
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-12 00:18:46 +00:00
Mike Fairhurst 6b40b26044 [nnbd_migration] Print warning when SDK_PATH is set and things go wrong.
Also clean up sanity checking code a little bit.

Change-Id: I4274dad42687a4dc419090d656ec56168c982c29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150661
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-11 17:19:51 +00:00
Paul Berry 2a5c122d4a Migration: Fix EdgeBuilder._unimplemented if node==null
Change-Id: Id1a297f1ee5eaf4d7111ad081a0a8c49cb334303
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150801
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-11 16:14:42 +00:00
Sam Rawlins 6ac9749546 Update nnbd_migration README with more details.
* Use title case on all headings.
* Link to https://dart.dev/null-safety and
  https://dart.dev/tools/pub/cmd/pub-outdated
* Remove any text which suggests to publish. Official docs warn
  strongly against using in production.
* Mention `pub outdated --mode=null-safety`.
* Mention migrating a clean code repository.
* Add more text about committing along the way.
* Make clear that the tool provides no revert capability.

Change-Id: I7914dc904a93046ce2508c51cae158ac39e889af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150822
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-11 03:33:25 +00:00
Samuel Rawlins 5a32ff0d7f Revert "Bump cli_util to 0.2.0; implement new methods"
This reverts commit ebcc6dc2a2.

Reason for revert: Broke golem. I think there are more implementations of Logger than I realized.

Original change's description:
> Bump cli_util to 0.2.0; implement new methods
> 
> This fixes the issue of progress indicators being shown during tests.
> 
> Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,jcollins@google.com,mfairhurst@google.com,srawlins@google.com

Change-Id: I52ac0f5d96a161534c28cc160c2a2b3b364ad511
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150693
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-06-10 23:59:05 +00:00
Sam Rawlins ebcc6dc2a2 Bump cli_util to 0.2.0; implement new methods
This fixes the issue of progress indicators being shown during tests.

Change-Id: I39fd68cfeca70a63d088aceb4325b42c53766afd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150669
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-06-10 22:10:06 +00:00
Paul Berry ae3b975373 Migration: exit early if an exception occurs
Change-Id: I108b64d75f9eb4ab376dfacaaeafcac1ef333755
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150580
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-06-10 13:50:27 +00:00
Paul Berry aa2566410f Migration: Add a flag to allow the user to ignore exceptions.
This should allow users to work around bugs while waiting for fixes
from the migration team.

Change-Id: I04fe08b4753ee1377a60ec60728a16560847536f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150542
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-10 13:50:27 +00:00
Mike Fairhurst 2a3d15e16f [nnbd_migration] Decorate Never type.
Both John and I have hit this in our own projects, seemed worth fixing.

Change-Id: Ic053287d365b92cbfd72448fe401ca627891f802
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150663
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-06-10 04:24:17 +00:00
Paul Berry 3aad249fe2 Sort declarations in preview_site_test.dart
Change-Id: I6154bcff1b6421207ef3c76b5679a1d5d3b6a4ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150541
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-09 15:14:21 +00:00
Paul Berry 9907b0327b Migration: add an api_test of a14n's repro for #41397
Bug: https://github.com/dart-lang/sdk/issues/41397
Change-Id: I271b8d961faf12d84f5ebd28ac44ec1d8490b465
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150540
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-06-09 13:58:16 +00:00
Paul Berry e4aaa1146b Sort declarations in migration_cli.dart
Change-Id: I05025f629080725f39a762c1d9f54d3aac7bf950
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150463
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-06-08 23:44:50 +00:00