Commit Graph

936 Commits

Author SHA1 Message Date
Mike Fairhurst 18814410a4 [nnbd_migration] Record edge origin for explicit call parameters
Change-Id: I33ccf611d1998478c84c4b3e0576ab2e3db906bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137651
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-28 23:26:22 +00:00
Mike Fairhurst 734ad9c00c [nnbd_migration] Add an edge origin for type name parameters.
Change-Id: Ifad0a0ae6e641360ac5be5eea5c61e667be33cbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137432
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-28 23:26:22 +00:00
Konstantin Shcheglov c9884ccf52 Analyze SDK with non-nullable experiment enabled, update MockSdk.
Initial:  https://dart-review.googlesource.com/c/sdk/+/134401
Reverted: https://dart-review.googlesource.com/c/sdk/+/134802

Internal presubmit is green.
https://test.corp.google.com/ui#id=OCL:294345942:BASE:297377939:1582738004318:fb4ae9fe

Change-Id: I25e6445bd0241a89850dff3d88ece0edd768053a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135241
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-26 21:08:21 +00:00
Janice Collins 31053a8c01 Add analyzer run support to steamroller and minor QOL improvements.
Change-Id: I4ffadba54e5d1485307c9b98858d80f5bdbcccf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136854
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-26 16:57:46 +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
Paul Berry da22aa9910 Migration: additional postmortem support.
This CL adds the following functionality to the migration postmortem
utility:

- The "steps" subcommand now prints both upstream and downstream
  migration steps (previously it only printed downstream steps).

- The "files" subcommand lists all input files for which at least one
  decorated type was stored.

- The "decorations" subcommand lists all the decorated types for a
  given input file.

- The "node" subcommand shows details about a single node, including
  any edges connected to it.

Change-Id: I034f13ffd7efa340e1cc50bf9039372f78da5027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136840
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-25 16:21:21 +00:00
Janice Collins 4c93115390 Upgrade steamroll_ecosystem to handle all hacks and run dartfix
end to end.

Change-Id: Idef5a99483abc79469c543435ea44289c000080a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135720
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-24 22:44:19 +00:00
Paul Berry 7911b6a989 Migration: fix handling of part files.
This CL fixes several minor bugs:

- In info_builder.dart, we were trying to apply SourceInformation from
  the defining library to all its parts.

- In NnbdMigrationTestBase, we were trying to fully migrate each file
  before processing any other files.  We need to prepare each input,
  then process each input, then finalize each input.

- In NodeBuilder, we were failing to send part file sources to
  NullabilityGraph.migrating().  As a result, methods declared in part
  files were being treated as already migrated, so they were getting
  the wrong kinds of nullability nodes.

- In _ProvisionalApiTestBase, we were sometimes visiting parts before
  discovering what libraries they were part of, causing inconsistent
  resolution results.

I'm hoping this will be sufficient to address
https://github.com/dart-lang/sdk/issues/40670.

Change-Id: I07d693b31b6cf64bc6f72126f5ef4792b29e5029
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136521
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-20 19:55:18 +00:00
Paul Berry fa38644450 Migration: handle dead code removal in awkward places.
Usually when migration removes dead code it can just delete it
(e.g. because it's removing a statement from a block and blocks can
contain any number of statements).  However, in certain contexts dead
code must be replaced with something else, such as an empty statement.

Change-Id: I65faf017897215d750395dc78a2bf8a157d8dce0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136441
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-19 17:39:44 +00:00
Paul Berry 2fa27b5d57 Introduce a "postmortem output" for nullability migration.
The postmortem output is currently only generated if the static
constant NullabilityMigrationImpl._postmortemPath is non-null.  The
generated file can be analyzed using
pkg/nnbd_migration/tool/postmortem.dart.

Change-Id: Ic5bf7aecc4176306839c00237eed668c2cd42571
Bug: https://github.com/dart-lang/sdk/issues/40624
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136003
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-19 16:44:40 +00:00
Konstantin Shcheglov cef02fff52 Merge Dart2TypeSystem into TypeSystemImpl.
Just mechanical movement of methods.

Change-Id: Ieb62190d2d531652b50cd233145f3dea22c00d97
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136302
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-18 22:37:35 +00:00
Mike Fairhurst 5e341835bc [nnbd_migration] Fix stack overflow on missing element decorated type.
This was causing 9k exceptions and slowing the flutter migration from
2:40 to 14:40.

There are 52 elements that don't get a decorated type in flutter due to
the abnormal usage of part files for the animated icons test.

The re-resolution stage of fixbuilder would then try to get the
finalType of these elements, but no decorated type for them exists, so
it would throw this exception. However, since the throw expression
stringifys the element, the element would go back to the hooks that try
to turn it into a finalType, which results in the same failure, until a
stack overflow.

Change-Id: Ib4c4746728e8bc6e583e133e91dcc0ba83e1b911
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136040
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-02-15 00:34:10 +00:00
Mike Fairhurst 0216ac8558 [nnbd_migration] Fix crash aggregating fixes on cascade property target
The target of a property access can be null if it is a cascade. If that
access is then modified, fix aggregator gets a NPE. This issue is not
true for index & method calls, same fix applies.

Change-Id: I98eac3c8f7eba5300b30ff366ee227430726440c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135963
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-02-14 21:45:47 +00:00
Paul Berry d5e6ab4195 Migration: propagate non-null intent through compound nodes.
A compound node represents a logical OR ("this node is nullable if and
only if one or more of its components is nullable").  Therefore, if
*all* of the components of a compound node have non-null intent, we
should consider the compound node itself to have non-null intent.
This fixes a problem that was preventing the migration tool from
respecting a "/*!*/" hint applied to the type parameter of a typedef.

Change-Id: Iec2f9d6968378707ba692be7b97f750cf53a8b85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135786
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-14 21:25:01 +00:00
Konstantin Shcheglov 6ae2a011d5 Use named parameters in TypeParameterTypeImpl.
Change-Id: I643acc61f53dfaf2e0c9bec7970fa6c33ff26850
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135964
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-14 21:19:26 +00:00
Mike Fairhurst 89db9ec241 [nnbd_migration] Only propagate exact nullability over uncheckable edges
Bug: 40551, 40552
Change-Id: Ib62dd2d9d1685956e3bf6f63a318888f3cd43904
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135762
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-02-14 18:57:47 +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
Janice Collins e0e438bf8b Implement analysis options modification.
Change-Id: I899067652bf00b3273559b59969d6b7c30883900
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135343
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-11 20:14:06 +00:00
Paul Berry 63b5d2b053 Migration: Allow null info when introducing as.
Usually we have good information from the nullability graph about why
we need to insert a cast, but sometimes we don't.  For example, when a
cast needs to be inserted because NNBD doesn't allow implicit
downcasts, we often can't give any additional information beyond "a
cast is needed here now".

We allow info to be null in these cases to avoid an assertion failure.

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

Change-Id: I7639374f92820faf04bda2aeda96d0e38f07e8d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135161
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-10 20:19:54 +00:00
Paul Berry a017944035 Migration: fix hard crash in trial_migration when migrating package:async.
There were two problems:

1. An info object isn't being properly passed to
   NodeChangeForExpression, causing an assertion failure during the
   FixAggregator stage.  I've modified the assertion check so that it
   happens earlier, during the FixBuilder, so that the exception is
   caught by permissive mode logic and doesn't cause a hard crash.
   I'll work on fixing the assertion in a follow-up CL.

2. The hack described in https://github.com/dart-lang/sdk/issues/40536
   was causing a bogus assertion failure in
   _PassThroughBuilderImpl._checkParenLogic.  I've weakened the
   assertion slightly so that for now, the hack won't cause trouble.
   See the issue for more information about what's happening--this
   should be cleaned up eventually but it's probably not high
   priority.

Bug: https://github.com/dart-lang/sdk/issues/40533
Change-Id: Iee832fbd07e54b02d2c52f79a097ff9d973cda9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134980
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-02-10 20:19:54 +00:00
Paul Berry 1554a119ed Migration: add explicit parameter types to function literals when necessary.
Under NNBD rules, certain function literals have their types inferred
as `Object?` instead of `dynamic`.  We need to add explicit `dynamic`
to prevent follow-on errors if those parameters are used in a dynamic
fashion.

Change-Id: I12bfd3a3da2bda1ae11b01a5d029dbea3d512cb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134567
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-07 23:07:27 +00:00
Konstantin Shcheglov 6f6797e745 Add NullSafetyUnderstandingFlag, update APIs to use it.
DartType.== implementations ignore nullability if the flag is not true.

TypeSystem APIs eliminate nullability from types before doing anything.

Internally analyzer continues using actual nullability for types.

Package nnbd_migration opted into NullSafetyUnderstandingFlag.

Bug: https://github.com/dart-lang/sdk/issues/40500
Change-Id: Ifeea28c01adf1dc59ed2da675b4a62c6334d529a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134865
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-07 21:38:06 +00:00
Janice Collins 7869bc39c6 Steel thread through fantasyland.
This includes a mostly feature-identical version of tool/migrate_ecosystem.sh, written in Dart.


Bug: https://github.com/dart-lang/sdk/issues/40280

Change-Id: Ib3fe2f353208038ac6c3f035fcdb17f638c68e49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134786
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-02-07 20:27:16 +00:00
Konstantin Shcheglov 1f47e5b23d Revert "Analyze SDK with non-nullable experiment enabled, update MockSdk."
This reverts commit 545b80ef0e.

Reason for revert: this is a breaking change for MockSdk users, actually much more serious issue for un-forking SDK. https://github.com/dart-lang/sdk/issues/40500

Original change's description:
> Analyze SDK with non-nullable experiment enabled, update MockSdk.
> 
> Change-Id: I80264a6533045c33ed794a5938f6719f3b5a6d0b
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134401
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>

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

Change-Id: If8c3d8322986b01012fa76f9c928f35309c00e3e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134802
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-06 22:55:29 +00:00
Konstantin Shcheglov 545b80ef0e Analyze SDK with non-nullable experiment enabled, update MockSdk.
Change-Id: I80264a6533045c33ed794a5938f6719f3b5a6d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134401
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-06 18:04:02 +00:00
Janice Collins eba2741166 Use analyzer filesystem implementation.
Change-Id: I071945c0f04c14474758b94f3ca560a2fbf7d2a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134543
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-02-05 22:33:19 +00:00
Paul Berry c9b66b222e Migration: propagate non-null intent into function literals.
Previously, if a function literal was used in a context where a
function returning non-null was expected, but the function literal
might return null, the migration tool inserted a cast that was
guaranteed to fail.  Now it propagates non-null intent into the
function literal, so that the appropriate null checks happen inside
the function literal.

Change-Id: Ia62d18bc3b9955e84b09b846ea913607b305677d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134504
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-05 21:35:19 +00:00
Paul Berry fecab44f59 Migration: Improve the tracking of type parameter bounds.
This CL extends ElementTypeProvider so that it also tracks type
parameter bounds.  This allows the FixBuilder to reason correctly
about the what generic function types will look like after migration,
and that in turn prevents it from trying to add unnecessary casts.

Change-Id: I3c909a3b5ba14bf9f2aad4e58d0981c1b7b5bdd2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134412
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-05 20:51:49 +00:00
Paul Berry 4df17ee697 Migration: clean up how decorated type parameter bounds are tracked.
We now track decorated type parameter bounds similarly to how we track
ordinary type parameter bounds in the FixBuilder, by having a single
static instance of a DecoratedTypeParameterBounds class that keeps
track of the mapping.

Change-Id: I49196e8a506ca8765857b3d47a355b7aaaa1918e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134411
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-02-05 20:51:49 +00:00
Janice Collins b59d3974d1 Consolidate dependency injection and set up FantasyWorkspace tests.
Change-Id: I25a3d6a3a0b94c2918cf77f41f1ceece903506e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134400
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-02-05 16:24:54 +00:00
Konstantin Shcheglov d025cd9378 Use DartType.getDisplayString() instead of toString().
Change-Id: Ibe5aa728058778bee42a1d87f4788da573a87d4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134462
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-05 07:33:19 +00:00
Paul Berry 655fcda015 Migration: rework how ElementTypeProvider overrides element types.
Previously, each piece of analyzer code needed during the FixBuilder
stage of migration needed to use the ElementTypeProvider interface to
access element types (rather than reading the types from the elements
directly), in order to ensure that the proper post-migration types
were used when building fixes.  This required a lot of plumbing, and
there was a high risk that we would accidentally fail to use the
indirection mechanism in a key location and access the elements
directly.

This CL changes the approach so that the ElementImpl classes
themselves are responsible for indirecting through
ElementTypeProvider.  This means that we can back out all the
plumbing, and there is no risk of accidentally failing to use the
indirection mechanism.

Change-Id: Ic1a0acc37f0350fc13b487f73fc1ad5225d7a090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134360
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-02-04 22:29:20 +00:00
Konstantin Shcheglov 05dcf371e7 Remove 'withNullability' from TypeImpl.toString()
Bug: https://github.com/dart-lang/sdk/issues/40460
Change-Id: Icd967df0252a9fd7ff9941ca7158b7df0190c961
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134384
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-02-04 21:19:06 +00:00
Janice Collins 1d932f7450 Add a 'run' feature to MultiFutureTracker.
This makes a certain idiom using MultiFutureTracker more compact,
namely blocking on the completion of the closure.

Change-Id: I8872ce882da0b20775c416895047cc18abd2801a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134248
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-02-04 18:57:18 +00:00
Paul Berry e989e90346 Migration: avoid ambiguities when adding a cast after a function expression.
When adding a cast to a function expression like `() => null`, we need
to add parentheses, so that we produce `(() => null) as Type`, rather
than `() => null as Type`, which makes the cast appear to apply to the
function body expression.

Change-Id: Ib5ae93df5b840a832c10941e47fa092a4f764eea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134044
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-03 19:59:38 +00:00
Paul Berry 763ce812ea Migration: properly handle type parameter types with nullable bounds.
This required adding logic to the `TypeParameterType` case of the
`toFinalType` function, so that we look up the decorated type of the
type parameter bound, and convert it to a final type as well.
(Previously we were just using the bound stored in the element model,
which was in many cases the bounds from prior to migration, and hence
it was a `*` type so it behaved as though it was non-nullable).

This required moving `toFinalType` into the `Variables` class so that
it could look up the decorated types of type parameter bounds.

Fixes #40355.

Change-Id: I53c2636aef6954500589e924b9755a297c2b30f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134061
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-02-03 19:59:38 +00:00
Janice Collins bd2e6adb74 Implement FantasySubPackage.
Also splits FantasyRepo into FantasyRepoImpl and an abstract class,
and unifies some of the filesystem mocking in a helper class.

Change-Id: Idb9ac7bf13238116448a46f551236e41cda83471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134121
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-03 16:55:25 +00:00
Paul Berry aa5a5ff5a8 Migration: Improvements to graph debug output.
Two minor fixes:

- Ensure that the immutable nodes `always` and `never` are always
  drawn with the `shape=none` attribute.  (Previously, the first time
  we encountered an immutable node we would draw it in the style of a
  mutable node, which made things very confusing).

- Add a space before `style=filled` in the graphviz output.
  Previously we would output things like
  `n21 [label="type(13) (ordinary nullable)"style=filled]`,
  which graphviz seems to do ok with but seems inadvisable.

Change-Id: Iefcb4005c9bb2e24ae8d80552e5e4a23ec062c56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133868
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-01-30 21:33:12 +00:00
Paul Berry ab6d0ef178 Migration: change implicit downcasts to explicit ones when necessary.
Note that downcasts from dynamic may still be implicit.

Fixes #38481.

Change-Id: I35558ed3578707cc640108b85790adb042e88ee2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133865
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-01-30 21:33:12 +00:00
Janice Collins 1a6a5b997d Implement FantasyRepo.
Clone and update repositories.  Basic end to end test and a primitive
mocking setup using dependency injection for testing.

Change-Id: I3a61f6fd86da6d5b8d79c0124a756dbfc70c4614
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133744
Commit-Queue: Janice Collins <jcollins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-01-30 15:43:18 +00:00
Paul Berry 9b6394c484 Migration: Fix toFinalType for top bounds.
To avoid inserting unnecessarily complex casts, we want to normalize a
type like `void Function<T extends Object?>()` to the equivalent `void
Function<T>()`.

Change-Id: Ied10e7735511b732eaeca027e621b4ef6997df59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133820
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-01-30 04:06:10 +00:00
Paul Berry 2492661ed7 Migration: Add a type parameter to NodeChange.
This improves our type safety a bit, by making it clear from the type
of a NodeChange object what AST node types it is prepared to act on.

Change-Id: Ie1202cd5377aa31162d76e2da7a93d0edaa11fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133746
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-01-30 00:41:30 +00:00
Mike Fairhurst 124f9b3fe0 [nnbd_migration] Handle downcast from FutureOr<T> to T.
fixes https://github.com/dart-lang/sdk/issues/40364

Bug: https://github.com/dart-lang/sdk/issues/40364
Change-Id: I5e4b70e63daecfe9470127bcae4c5481c6e747f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133763
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-29 20:02:10 +00:00
Mike Fairhurst 6e53629f3b [nnbd_migration] Handle LUB(Never, C<T>).
Fixes https://github.com/dart-lang/sdk/issues/40363

Bug: https://github.com/dart-lang/sdk/issues/40363
Change-Id: I047a5ef9c58c22e6cf4603551015097049f1ac83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133662
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Janice Collins <jcollins@google.com>
2020-01-29 19:50:50 +00:00
Janice Collins 4ee5fd243f Move the parallelization restriction into SubprocessLauncher.
This eliminates a lot of really noisy boilerplate in the upcoming
FantasyRepo implementation.  The test only verifies that the pathway
works, we rely on MultiFutureTracker working to actually restrict
properly.

Change-Id: Ia88d0b24dd739ab1cd4a661325214395bf37eef3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133742
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-01-29 18:32:36 +00:00
Paul Berry 0ca9e8522e Migration: add explicit types to variable declarations when needed.
Partly addresses https://github.com/dart-lang/sdk/issues/39404.

Change-Id: Id8139b18bf8339df0eead48cc8648cb5f030acf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133741
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-01-29 18:30:46 +00:00
Paul Berry e0dff825b9 Migration: Add offsets to more inferred type nodes.
This should make it easier to understand the nullability graph when
debugging a test case.

Change-Id: Ic9cf1d8b460f76776b5433714ba3099cae00ccbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133740
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-01-29 18:30:46 +00:00
Paul Berry 208d8c2e52 Migration: Rework FixAggregator to reduce order dependencies.
Previously, FixAggregator provided one NodeChange-derived class for
each possible kind of fix; if multiple fixes had to be made to a
single AST node, its client (FixBuilder) was required to nest them in
the appropriate order.  FixBuilder accomplished this by carefully
controlling the order in which it decided on fixes.  Unfortunately,
this careful control of order is becoming burdensome for FixBuilder to
maintain.

With this change, the class hierarchy of NodeChange mirrors the class
hierarchy of AstNode, with different fields for each possible kind of
fix.  This means that FixBuilder can decide on fixes in whatever order
is convenient.

Change-Id: I1c79cfc37b6289051b3927c67867b77a1dbb5ebf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133541
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-01-29 18:30:46 +00:00
Paul Berry 7467988bbc Migration: simplify edit plans for changing ?. into ..
I realized that I can use the same "pass through" infrastructure for
these kinds of edits.  This should help prepare for a future CL in
which we can aggregate together more complex changes, such as
introducing an "as" cast at the same time as changing `?.` into `.`.

Change-Id: Ie3af07a3563c44d62d4ed34d2a477eef6fae358f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133540
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-01-29 18:30:46 +00:00