Commit Graph

1123 Commits

Author SHA1 Message Date
Paul Berry 1c86b2f5f6 Migration: tolerate relative imports into lib.
Prior to this fix, if the user's package had a relative import from
outside `lib` to inside `lib` (e.g. from `test` to `lib`), the
migration tool would regard the imported file as being reached via a
`file:` URI.  This caused it to get confused and complain that the
user had a dependency on unmigrated code (this happened because the
check for dependency on unmigrated code excluded the user's files via
their canonical URIs, and files inside `lib` use `package:` for their
canonical URIs).

To fix the problem, we modify the check for dependency on unmigrated
code so that it excludes the user's files via their path rather than
their URI.

Note that relative imports into the `lib` directory are discouraged by the style guide*, but it still seems worth fixing this bug since they do crop up in the wild.

*https://dart.dev/guides/language/effective-dart/usage#dont-allow-an-import-path-to-reach-into-or-out-of-lib

Fixes #45780.

Bug: https://github.com/dart-lang/sdk/issues/45780
Change-Id: Iff41ca0059d78bbb812dd6f421be6458e7049895
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196344
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-21 22:04:30 +00:00
Konstantin Shcheglov 9dd51c80bd Deprecated getFile() and getSourceKind(). Added getFile2() instead.
R=brianwilkerson@google.com

Change-Id: Ia52967472077abd73cdf4df1320dd71b5dee98b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/196060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-19 23:57:19 +00:00
Konstantin Shcheglov db2aceaa42 Add getResolvedLibrary2(), deprecate getResolvedLibrary().
Change-Id: If502203708ed4c6a64e7054c2b12970eac11755b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195497
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-04-17 16:51:07 +00:00
Konstantin Shcheglov 26d9fbbd04 Add getResolvedUnit2(), deprecate getResolvedUnit().
Change-Id: I0217fefb2747f2f9bd757bc041b53acaf3d1a8f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195495
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-04-16 21:33:54 +00:00
Paul Berry 1e68c47e68 Migration: make --ignore-errors affect the "rerun" button.
Fixes #45665.

Bug: https://github.com/dart-lang/sdk/issues/45665
Change-Id: I8d238f5117fdaf8b7ffbe31dc8b1dfcb7a52a58d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195183
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-15 18:26:47 +00:00
Paul Berry 4e353ca98d Migration: properly assign types to collection literals.
Fixes #45583.

Change-Id: Ic411856968ec68b5ee6dd74718d08a4e9ea9c0d3
Bug: https://github.com/dart-lang/sdk/issues/45583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-15 17:15:47 +00:00
Paul Berry 3186fa521e Migration: handle more complex extension method invocations.
Fixes #45574.

Bug: https://github.com/dart-lang/sdk/issues/45574
Change-Id: Iecf7acfebc1c59e5518edec4b8c287996d80c80d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-14 22:56:46 +00:00
Franklin Yow 03101c0c2b Update LICENSE
Changes to comply to internal review

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

TEST=CL contains no code changes.

No-Try: true
GitOrigin-RevId: 65796784e5fdfddaa021b5c55ad435b1db419700
Change-Id: I085a948f16dc9a0de128ed0bd456ae69adf6c124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193888
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2021-04-07 10:28:38 +00:00
Paul Berry a15e9bc3d2 Migration: disable "apply migration" button after handleAddHintLinkClick
Prevents file corruption if the user adds hints and then tries to
apply the migration result without running migration to account for
the hints.

Fixes #45571.

Bug: https://github.com/dart-lang/sdk/issues/45571
Change-Id: Id11584a1d8b7a6b35127ad828d37b3ef837a5e65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194009
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-06 05:12:56 +00:00
Paul Berry 0291de4bcf Migration: do not attempt to modify named expressions.
When a method call includes a named argument such as:

  f(named: x)

the analyzer represents the AST node `named: x` as an Expression.  But
it's not safe for the migration tool to try to modify it in the same
way that it modifies other expressions (e.g. by surrounding it with
`(...) as Type`), because that would produce a parse error.

Improves the analyzer behavior for #45583.  Note however that this is
not a complete fix yet; see the test case included in this CL for why.

Bug: https://github.com/dart-lang/sdk/issues/45583
Change-Id: I79ffcdd22654221ff7e0784b3355ecfd2ec0f01c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194008
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-06 05:02:16 +00:00
Paul Berry 72bc3134c5 Unify "why not promoted" representations for for-loops and other writes.
This CL changes the responsibility for doing flow analysis of the
implicit variable write in a `for-in` loop as follows: if the `for-in`
loop does not declare a variable, but it assigns to a local variable,
then the flow analysis client is responsible for calling `write` on
entry to the loop.

This in turn allows us to use a single code path to track "why not
promoted" information related to all possible local variable writes;
we no longer need as much special case logic to handle for-in loops.

To make the analyzer integration slightly cleaner, we change the
argument type of FlowAnalysis.write to Node rather than Expression, so
that the analyzer can pass in the ForEachParts object when analyzing a
for-in loop.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I24b47be8eac2e276cd291a5b2f2e4444c911138f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193837
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-04-03 15:28:36 +00:00
Paul Berry 0e8a84173e Migration: fix futures using .then rather than as
Previously, if the migration tool encountered a Future expression with
a bad type (e.g. a Future<String?> where a Future<String> was needed),
it would "fix" the problem by introducing a cast.  That is nearly
always the wrong thing to do; what we want to do is null check the
value that the future *completes* with.

This CL changes the migration tool so that it fixes this case by
appending `.then((value) => value!)` to the future expression.

Fixes #45472.

Bug: https://github.com/dart-lang/sdk/issues/45472
Change-Id: I7a35b54f673936e2e4b0f8f3a077ba8bf684b4eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193700
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-31 17:48:19 +00:00
Paul Berry 32806f2e8d Migration: fix handling of loadLibrary.
Fixes #45396.

Bug: https://github.com/dart-lang/sdk/issues/45396
Change-Id: I150a1ded64ae2c22e5598d2023e605a45ddfe680
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193041
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-25 20:29:34 +00:00
Paul Berry 9d0d1fb388 Sort declarations in variables.dart
Change-Id: I5bbf3be04e1fc5c1354d3c3d39669b0bfefb9a50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193040
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-25 19:28:14 +00:00
Paul Berry 5fc5c0ba6d Migration: Properly escape strings in calls to querySelector.
Fixes #45326.

Bug: https://github.com/dart-lang/sdk/issues/45326
Change-Id: I990b230b7ee1df6d998dbb412814daa668c25e76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191383
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-25 14:43:23 +00:00
Paul Berry 128fef8808 Migration: clarify error messages when preview server doesn't respond.
Previously, if the preview server couldn't be reached because it had
exited, we would generate an error message with an obscure looking
stacktrace.  I believe this was prompting users to file bug reports
against the migration tool, when in fact all they needed to do was
restart the migration process.  Hopefully this better error message
should help avoid confusion.

I also took the opportunity to improve the error message that is shown
if the user does restart the migration tool but tries to keep
interacting with it using an old authToken.

Fixes #45202.

Bug: https://github.com/dart-lang/sdk/issues/45202
Change-Id: I83e0ca99d789739e614bfff2d535d427a2fdfbb2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192732
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-24 17:03:42 +00:00
Ben Konyi a49bea950d [ CLI ] Use 'project' instead of 'package' in CLI help messages
Initial updates, related to
https://github.com/dart-lang/sdk/issues/45279.

Change-Id: I459e719ad6e92378f9240a612e0bd8229d0fcb2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192727
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-03-23 23:05:33 +00:00
Paul Berry 77fbd1d6e5 Migration: avoid crash on unreferenced part files.
Fixes #45369.

Bug: https://github.com/dart-lang/sdk/issues/45369
Change-Id: Ic414de3c002f8993567eed39e049d90ea741b381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192520
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-22 22:55:45 +00:00
Paul Berry 7655529252 Sort declarations in migration_cli_test.dart
Change-Id: I2cc6e3d5fd4de62aaf4ba2144432094951843837
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192484
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-03-22 22:55:45 +00:00
Brian Wilkerson d00ef8611a Update the server protocol to support passing back the line and column numbers for the end of a range
Change-Id: I8310e4a32cacbe98310c1dbaa3b3563b1ff1a1ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191862
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-03-18 19:22:23 +00:00
Paul Berry 9478b71000 Create a tool for extracting resources from resources.g.dart.
This should be helpful in debugging minified stacktraces reported for
the migration tool, such as #45326.

Bug: https://github.com/dart-lang/sdk/issues/45326
Change-Id: I44c697cfdfd6a06e8af3a2592321a1e9156ca929
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191380
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-16 17:21:08 +00:00
Paul Berry 9d395f82cf Sort declarations in migration.dart
Change-Id: Id3d76e47c8c635131a767af0accd19d313296a26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191382
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-16 17:06:22 +00:00
Paul Berry c509ad1e41 Change "could not" to "couldn't" in error messages
See comments at
https://dart-review.googlesource.com/c/sdk/+/186320/4/pkg/analyzer/lib/src/generated/resolver.dart#3423.
On the recommendation of the documentation team, we use a more
informal tone in messages.

Change-Id: I0c243669ebd91b8f4a745530582e0f829769a754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-10 15:26:38 +00:00
Paul Berry 73f9d0cd26 Flow analysis: Remove unnecessary argument from tryFinallyStatement_end.
Flow analysis stopped using this argument (the AST node for the
finally block) some time ago, but I kept it around so I could assert
that clients didn't unnecessarily store assigned variables info for
it.  It's been long enough now that we can eliminate this code
entirely.

Change-Id: I8c64e2b4fc5b154f441ec2d057637f3dc9ced277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-10 13:14:08 +00:00
Konstantin Shcheglov 19e0673582 Revert "Return List<XyzElementImpl> from ElementImpl getters."
This reverts commit 645035bbb9.

Reason for revert: b/182098851

Original change's description:
> Return List<XyzElementImpl> from ElementImpl getters.
>
> Change-Id: Ice8a0feb6a0bd2599fcfd5ccc35c0b4242ed9530
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189620
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>

Change-Id: I33eff159d62813c35e7e00eee5b7d9dd4fb4e563
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189781
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-03-08 19:09:44 +00:00
Marcin Niemira a84ee9662c update regexp
Closes https://github.com/dart-lang/sdk/pull/45221
https://github.com/dart-lang/sdk/pull/45221

GitOrigin-RevId: 8728725779669558d519c9270bbf6e9e7e7c0f2d
Change-Id: I754f00f49df78230a6245a05c6647fc573c67a22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189383
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
2021-03-08 15:14:31 +00:00
Konstantin Shcheglov 645035bbb9 Return List<XyzElementImpl> from ElementImpl getters.
Change-Id: Ice8a0feb6a0bd2599fcfd5ccc35c0b4242ed9530
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-03-08 07:00:40 +00:00
Konstantin Shcheglov 0506b1b2d3 Deprecate setters in API of AST.
Change-Id: Ib2ec164ef87b3a5a4bf028d592552e37451abd35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-03-07 21:48:50 +00:00
Konstantin Shcheglov 53c8eda967 Keep more specific types for AnalysisContextCollectionImpl to avoid downcasts.
It seems to me that implicitly expecting DriverBasedAnalysisContext
is equivalent to explicitly stating this with types.

Change-Id: I16ec14e73030d9b34242a2f4ad582e93fc44afa7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189382
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-03-06 06:23:25 +00:00
Paul Berry 8be535350d Flow analysis: improve handling of types in "why not promoted" logic.
This CL plumbs the types of `this` and property get expression from
the CFE and analyzer into flow analysis, so that flow analysis will be
able to create more accurate "why not promoted" information for those
expression types.  This made it possible to eliminate a clumsy aspect
of the previous implementation, namely that we would consider a
promotion attempt like `if (x.y == null) return;` as an attempt to
promote the type of `x.y` to `Object`; now we compute the type the
user is actually trying to promote to, so we will be able to generate
more accurate "why not promoted" messages.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I67f9fc59e72103194a1ea6b1c4dfeae8aeb194a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/187064
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-03 23:16:55 +00:00
Paul Berry 32255a579b Migration: fix race condition with null navigationTree.
If the user tries to click around in the migration web UI before the
navigation tree has finished loading, the `navigationTree` global
variable will still be null; we need to allow for this possibility to
avoid a crash.

Bug: https://buganizer.corp.google.com/issues/181067935
Change-Id: I5398ac62bb4eb307aaa48ec39098b6ae0541a6a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-02 21:33:27 +00:00
Konstantin Shcheglov f1094d5c3a Use newPubspecYamlFile() to create pubspec.yaml files
Change-Id: I181a3f3f14810019731201bf43e27befa7bc5481
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-22 21:32:00 +00:00
Konstantin Shcheglov 875af7c991 Deprecated TypeProvider.futureType2/listType2/etc
Change-Id: Ia994be1e29b4d96b89d714beafcb9256a0cb4de6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/184641
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-12 17:26:07 +00:00
Konstantin Shcheglov 5a4b8240f9 Stop using FunctionTypeAliasElement in nnbd_migration.
Change-Id: I3dfc310d28f2f3127e61302dc31ab11ee55d51d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/182661
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-02-03 20:41:19 +00:00
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