Commit Graph

247 Commits

Author SHA1 Message Date
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
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
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
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 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 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
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 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
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
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
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 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
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 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
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
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
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
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
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
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
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 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
Sam Rawlins 3c6a3fba30 Migrator: Add some failing tests for extensions
Bug: https://github.com/dart-lang/sdk/issues/39387
Change-Id: I2187db2433255fd950789942712d215c2472db4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149005
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-26 23:24:22 +00:00
Sam Rawlins c958fa4fb9 Migrator: Fix nullable casts which are immediately null-checked.
Fixes https://github.com/dart-lang/sdk/issues/41397

Change-Id: I7e64cbb475b6387ad10a2895e67311edac3aa7d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146824
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-06 21:33:29 +00:00
Sam Rawlins 57ff9b73f9 Migrator: Support nullable function-typed parameters
Feature includes:
* function-typed formal parameters
* function-typed field formal parameters
* overridding parameters
* nullability hints
* adding `required`
* optional parameters

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

Change-Id: I1d9b1a50a9a6a77651fe6179b66c8301c8ab9408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/146029
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-05-05 20:03:07 +00:00
Sam Rawlins 5ab3f3506f migrator: quiver's checkNotNull implies non-null intent
Fixes https://github.com/dart-lang/sdk/issues/39315

Change-Id: I136975064c6aadf9b8548afe9b5928d4ee6775a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145569
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-04-30 16:15:32 +00:00
Sam Rawlins 5506769402 Count variables checked with ArgumentError.checkNotNull as not null
Fixes https://github.com/dart-lang/sdk/issues/39644

Change-Id: I552e87e7c57dd2c5a012b76d9c73c24fefb19785
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145025
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-29 22:35:18 +00:00
Sam Rawlins 61755dea19 Migrator: Infer late for test variables
Fixes https://github.com/dart-lang/sdk/issues/38291

This change also involves moving the "package" where test sources are
written and analyzed; It used to be /home/test (or /project in some
places); and a pubspec.yaml was written (or a .packages file) which
specified the package's name was "test". However, this conflicts with
adding an entry for a mock copy of the actual _test_ package. A
.packages file cannot have two entries for a package named "test", so
the package where all test sources are written is changed to "tests"
(located at /home/tests).

Change-Id: I462b88a814931dc2d4f1e72d07e3daf64768a399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144994
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-29 22:09:28 +00:00
Paul Berry 925e3fe782 Migration: detect weak-only code in conditional expressions.
This change adds the ability to detect when one branch of a
conditional expression is weak-only due to nullability.  For example,
in the following code:

  int f(int/*!*/ i) => i == null ? g(null) : i;
  int g(int j) => ...;

the call to `g` can only happen in weak checking mode.  The migrator
also now understands that j only needs to be nullable if i is
nullable.

Fixes #41555.
Partially addresses #41551.

Bug: https://github.com/dart-lang/sdk/issues/41555
Change-Id: I02c9c3072f0104db0f1a5b432fb1f2f8f06d5282
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144120
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-20 19:09:32 +00:00
Sam Rawlins a4c49f8fce migration_tool: Dummy edges
Helps with https://github.com/dart-lang/sdk/issues/40509 and
https://github.com/dart-lang/sdk/issues/38747

Change-Id: Iac7208ee38dcc6c0b055f9e46c2d755ad0388488
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143962
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-20 18:14:32 +00:00
Paul Berry fdc13e3f43 Migration: remove hints when performing migration.
Previously, if we migrated a code snippet like this:

  void f(int/*?*/ i) {
    /*late*/ int j = i/*!*/;
  }

the migration result would leave the hints and add the hinted text,
resulting in:

  void f(int?/*?*/ i) {
    /*late*/ late int j = i!/*!*/;
  }

We now simply remove the `/*` and `*/` surrounding each hint (with
whitespace corrections as needed), to produce:

  void f(int? i) {
    late int j = i!;
  }

Change-Id: Ic4e1216cb4693d73d71c9ab1a37d5cc15b8ef334
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143460
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-17 00:17:15 +00:00
Paul Berry 46b49d23ec Migration: track multiple fix reasons for expressions with complex types.
Change-Id: I1a1f78377ed64504e5315b5096914219dc625e78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143188
Reviewed-by: Janice Collins <jcollins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-04-14 23:33:46 +00:00
Paul Berry 49f6a49056 Migration: remove the PotentialModification class and some of its descendants.
This code was part of the old infrastructure that pre-dated FixBuilder
and is not needed anymore.

Change-Id: I697dbfcd325b2f1c38754890cc8f60679004f7c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142680
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-04-07 18:35:56 +00:00
Konstantin Shcheglov bac08fb339 Implement interfaces subtyping check using allSupertypes.
Change-Id: I43a4b98bae913895c7e176dd24a17fc5df7666e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-06 00:20:10 +00:00
Paul Berry f04053d767 Migration: do not union inferred types in overrides.
Previously, when handling an override such as:

  abstract class A {
    int/*?*/ f();
  }
  class C implements A {
    f() => 0;
  }

we would create a union edge between the implicit return type of C.f
and the explicit return type of A.f.  This was a problem because
nullability information can propagate bidirectionally through union
edges, so it could result in types unnecessarily becoming nullable,
e.g.:

  abstract class A {
    int/*?*/ f();
  }
  abstract class B {
    int f(); // Should not need to be made nullable
  }
  class C implements A, B {
    f() => 0;
  }

This CL fixes the problem by just making ordinary unidirectional edges
for overrides involving inferred types.

Change-Id: I63a5f1f640b5543fcf39304087592e984aa66694
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141853
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-01 12:07:44 +00:00
Paul Berry 8df442e414 Migration: don't use union edges for field formal parameters
Fixes #41182.

Bug: https://github.com/dart-lang/sdk/issues/41182
Change-Id: I485c1a502e34de758fdd0bc831bc18a665005bd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140911
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-03-27 21:13:47 +00:00
Paul Berry 08c6dd6164 Migration: add FixBuilder support for expression null check hints.
Previously, null check hints were only affecting the behavior of
EdgeBuilder, which meant that we handled simple cases like:

  int f(int/*?*/ x) => x/*!*/;

(because the EdgeBuilder wouldn't build an edge from the type of `x`
to the return type of `f`, so the return type of `f` would be
non-nullable int, and hence the FixBuilder would insert a `!` in order
to prevent an error).

But if there were some *other* reason for the destination type to be
nullable, then no `!` would get inserted.

This CL adds explicit logic to the FixBuilder to ensure that a `/*!*/`
hint causes a `!` to be inserted whether it's necessary or not.

Change-Id: I283bb9793d8d01408333f5b56562286bf19d8773
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140904
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-03-25 19:38:34 +00:00
Paul Berry 244b4247e9 Migration: better description text for edges.
Change-Id: I58651c927a741721283c3c4c951673a86aa7a1b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140883
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-03-25 19:38:34 +00:00
Paul Berry 94dadae052 Migration: add support for expression bang hints
Change-Id: I6199c02b16249aade611e316b3b845ea1386ff8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140440
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-03-24 20:35:15 +00:00
Paul Berry 529f52a05a Migration: handle field overrides
Change-Id: I21db786afa80a0e4811341ad605bf2657377810b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140255
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-03-20 20:23:23 +00:00
Paul Berry 2ec127a305 Migration: give nullability nodes human-readable names.
Change-Id: I86b510c6cc9afacb7d720af214c8f4e5a311c9ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138885
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2020-03-11 15:20:59 +00:00
Paul Berry 043af430c1 Migraiton: Add function names to trace output.
This makes them look a lot more like real stacktraces.

Change-Id: I0c060f72f8676ab6d5c0272532b90931b815fddf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138607
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-03-09 22:00:59 +00:00
Paul Berry a74253987b Migration: add trace functionality to the preview tool.
This establishes the base functionality.  A lot of follow-up work is
needed from here:

- Each trace should have an entry at the top of it pointing to the
  thing that was made nullable.

- The source code links in traces don't include lengths, so we can't
  highlight whole identifiers when the user clicks on a link.

- Description strings are currently generated by running toString() on
  the individual nullability nodes and edges, resulting in long-winded
  and useless descriptions.

Change-Id: Ibb370bae6bedc7a8c86092462785023002a48ac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138481
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-03-05 17:21:54 +00:00
Paul Berry eec7876eb2 Migration: prototype a "stacktrace-like" display of the principal cause of a nullability decision.
The principal cause may be displayed by invoking the "postmortem" tool
using the "trace" subcommand, followed by the id of the node for which
a trace is desired.

Change-Id: I5868b4bc979320bb46698b02c7b43b317205c487
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137429
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-03-03 01:24:17 +00:00
Paul Berry 85f6d51c3f Migration: infer nullability for uninitialized toplevel vars and static fields.
Fixes https://github.com/dart-lang/sdk/issues/40700.

Change-Id: I4b33b65961bf9c06c6ae68691f9e337dcee2af66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136901
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-25 16:21:21 +00:00
Paul Berry 6a165950f5 Migration: do not allow RHS of a typedef to be marked as nullable.
We should consider the nullability of the right hand side of a typedef
to be "never", since a `?` is not allowed on there.  Instead, we
should allow each use of a typedef to have its own independent
nullability.

Fixes a bug wherein we would erroneously migrate code like this:

  typedef F<T> = int Function(T);
  F<String> f = null;

Into the following:

  typedef F<T> = int Function(T)?;
  F<String>? f = null;

(Note the bogus `?` after `int Function(T)`).

Change-Id: I8535645303fc644c73617684b8bb3488462589ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136900
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-25 16:21:21 +00:00
Mike Fairhurst ffc3cd6e29 [nnbd_migration] Type arguments should get uncheckable edges
Change-Id: I5940fc80e8e7f1af5e1febf7ca4f95dd6178f149
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135629
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-14 18:57:47 +00:00