Commit Graph

936 Commits

Author SHA1 Message Date
Paul Berry 9cb0b678ce Migration: remove more explicit uses of never from EdgeBuilder.
With this change, we no longer use the "never" graph node for:

- instance creations

- explicit references to `this` or `super`

- the static type of `throw` and `rethrow` expressions

Change-Id: I995be86ee0f4d8002c70cf98e7e5d2767529d00b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125226
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-11-15 02:02:35 +00:00
Paul Berry ad4b93da9e Migration: stop using the "never" node for the type of literals.
Change-Id: I4195dd989d295dc9a468ada0e643c9a971f3a9d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125223
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-14 18:25:29 +00:00
Paul Berry eeb89b2e5b Migration: ensure that uninitialized fields are nullable.
Change-Id: I1dc0a2c80ea52566aa4eb6b5e9ce745ad635d517
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125220
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-14 17:03:07 +00:00
Paul Berry a2894e7864 Migration: make use of _graph.make(Non)?Nullable in EdgeBuilder.
This eliminates a few direct references to `always` and `never` nodes
from the edge builder.  It also fixes a latent bug where we were
failing to create a hard edge when handling "is" expressions.

Change-Id: I4c88432c97932eac3554cfcb75bbd634c0e2e4c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125061
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-14 16:56:06 +00:00
Paul Berry fc7f084a00 Migration: stop using always/never for inaccessible getter/setter types.
When migrating a reference to a field or top level variable, we have
to create a temporary type to represent the synthetic getter or setter
that is being referenced.  That requires creating some new nullability
nodes, to represent (a) the `void` return type of the setter, and (b)
the function type of either the setter or the getter.  These nodes
never actually get attached to the nullability graph (because a call
to a getter/setter can't access the function type, or the return type
of the setter), so it doesn't really matter what nodes we use.

This change switches to using fresh nullability nodes rather than
always and never for these inaccessible types.  This takes us one step
closer to eliminating the use of always and never outside of the
implementation of the nullability graph itself.

Change-Id: I33de35ba36bbca42731c5e2d827ccf972cd368dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124911
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2019-11-14 16:56:06 +00:00
Paul Berry 7735bf3c29 Migration: remove unnecessary recursive calls from _checkDowncast.
These recursive calls had no effect, since downcasting from `dynamic`
to any other type always succeeds.

Change-Id: I44e3c025e98dddd47e9789ab3543a369b5f74565
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124908
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2019-11-14 16:56:06 +00:00
Paul Berry 3bd7ed38fb Migration: fix handling of bound -> type param downcast.
I don't recall what I was thinking when I decided to change the
nullability of the type to "always" when doing this downcast--AFAICT
it doesn't make any sense.

Change-Id: I41d1d2a30722010d2b9b93bb53979ce881e24319
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124905
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-14 14:03:16 +00:00
Sam Rawlins 06aef10d76 nnbd preview: Remove descriptionPrefix; don't link Details which will link to some bizarre Never node
Bug: https://github.com/dart-lang/sdk/issues/39247
Change-Id: I6f34ecf745e8db75534affdeadc3d47acac079b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125062
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-11-14 01:09:35 +00:00
Paul Berry 5767cc1bfd Migration: do not use "always" node for dynamic dispatches in EdgeBuilder.
Change-Id: Ic9b62287d11e4adfe14082834fde8bee01624a28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125121
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2019-11-13 23:10:15 +00:00
Paul Berry 8452d2d188 Migration: change behavior of dynamic.
Previously, when the migration engine found a type that was implicitly
or explicitly dynamic, it assumed the type was meant to be nullable.
This seemed reasonable (since, after migration, `dynamic` indeed
allows null), but it caused unnecessary nullabilities to be
propagated.  With this change, the migration engine tracks whether
dynamic types can be nullable or not, just as it does for all other
types.  This cleans up a number of tricky corner cases in the
migration engine that were getting in the way of fixing up uses of
`always` and `never` nodes.

Note that if a `dynamic` type is determined to be non-nullable, it
will still be `dynamic` after migration; this change merely prevents
nullabilities from being needlessly propagated from that dynamic type
to other types.

Note that we still assume `dynamic` is nullable when it occurs in an
already-migrated library or as the result of a dynamic dispatch.

Change-Id: I380d0907f3489d0b84f3fdd7164113daae24274e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125084
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2019-11-13 23:10:15 +00:00
Paul Berry 8938a5ed2d Migration: make an edge origin for assignments of dynamic.
Change-Id: I75d037aa7ee890488a92e113f58094b5733a9b8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125004
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-13 00:27:32 +00:00
Konstantin Shcheglov c9ef7cc5e3 Deprecate Member.baseElement, use Element.declaration in analyzer.
Change-Id: I91d23558c7d0bd8ffa2e251e5d615d4e026923b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124940
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-11-12 22:35:07 +00:00
Paul Berry 3793a40e6a Migration: stop using always for decorating the type of explicit nulls.
Change-Id: I950c9b8e80bc647c5a42b5cb5c66babd7c4d41e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125008
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-12 22:19:16 +00:00
Konstantin Shcheglov 6cde7ce224 Deprecate synthetic FunctionTypeImpl constructor.
Change-Id: I7c2f834d7e9e532709b3d43b348e7588be659af9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124595
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-11-11 19:38:53 +00:00
Paul Berry 7c78ab75a5 Migration: allow already-migrated libraries to be opted in.
A core assumption of the migration tool is that the code being
migrated may have some dependencies that have already been migrated
(e.g. the SDK itself).  Of course these dependencies will need to be
analyzed as "opted in" libraries so that they can have nullability
annotations.

However, when the migration tool was first being developed, we didn't
yet have a migrated SDK, so the SDK was opted out and we just had to
pretend that it was opted in.

This CL prepares to switch over to a truly opted-in SDK by updating
the AlreadyMigratedCodeDecorator to handle opted-in code.

Change-Id: I797752401f8c7bf7cdf8d26d03d00d3d213a5127
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124466
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-08 13:53:17 +00:00
Paul Berry 7e8e66016a Migration: do not use always or never in already-migrated types.
Previously, when the code being migrated referred to a nullable or a
non-nullable type in an already-migrated library, we would use the
`always` or `never` graph node to represent the nullability of the
type.  This was problematic, because it made it difficult for
instrumentation to pinpoint precisely which element in an
already-migrated library was the cause of an expresion being
null-checked, or a type being made non-nullable.

We now create a fresh nullability node for each non-nullable type
coming from already-migrated code, with an edge to `always` or `never`
to ensure that the fresh node has the correct nullability, so that
instrumentation can see precisely which element it came from.

Since the migration tool doesn't traverse the ASTs of already-migrated
code, we can't report an AST node that caused such an edge, so an
`element` getter has been added EdgeOriginInfo to allow us to report
the element that caused the edge.

As before, types associated with already-migrated code are reported to
instrumentation via InstrumentationListener.externalDecoratedType.  As
a new enhancement, bounds of generic parameters in already-migrated
code are reported to instrumentation via
InstrumentationListener.externalDecoratedTypeParameterBound.

Change-Id: Ided4e96e2920f8d9062688f5a6fda29b9b71dd12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124000
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2019-11-08 13:53:17 +00:00
Brian Wilkerson b647e327aa Fix an assertion to support migration of part files
I'm not sure where the test for this should go. I found it while
migrating vector_math.dart.

Change-Id: I0c1c5ba91375b2a36540f4c270cef6dc9558a745
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124103
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-11-06 20:18:31 +00:00
Konstantin Shcheglov 2438fe10cb Rename BottomTypeImpl to NeverTypeImpl.
The corresponding element is Never, and the spec says "the type Never".

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

Change-Id: Icb6427ef13fa6ee74bd07d5345e68402a1b90b6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123943
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-11-03 19:03:02 +00:00
Brian Wilkerson 9bffff6dfc Fix exception in migration of ?? operator when the right hand side is a generic type
Change-Id: Ie372522f9493e2ccea8284f8583b0f43153adbbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123884
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-11-01 21:52:48 +00:00
Brian Wilkerson eab70c2673 Visit annotations on classes in EdgeBuilder
This also makes the annotation tracker an instance field rather than a
static field.

Change-Id: I3f636047b7cbddc98536cd10b209e22546d6019b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123694
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-11-01 15:45:52 +00:00
Johnni Winther 00c2962db8 [cfe+analyzer] Move messages, scanner and parser to package:_fe_analyzer_shared
Change-Id: I4fa87aee65f30a9868a6cf8f0342591869ece7ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123663
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-01 09:37:57 +00:00
Paul Berry 499815842c Create a package to hold code shared between front_end and analyzer.
Previously such shared code was in the front_end package, but that
created problems because there is a lot of code in front_end that
isn't intended to be shared with the analyzer (including, notably, the
dependency on kernel).

This CL just moves over the flow_analysis logic to the new shared
package.  Follow-up CLs will move over other shared logic and tests.
The end goal is that the analyzer package will no longer have a
dependency on front_end.

Change-Id: I5642d6565204422d79808ca47648462db85e442a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123624
Reviewed-by: Jens Johansen <jensj@google.com>
2019-10-31 13:05:53 +00:00
Paul Berry d50c158d42 Flow analysis: fix analyzer "desugaring" of try/catch/finally statements.
Flow analysis requies the client to desugar a try/catch/finally
statement into a try/catch statement nested inside a try/finally
statement (or, in the analyzer's case, to make calls to flow analysis
as though such a desugaring has been done).  The analyzer was doing
this incorrectly:

- It was always calling the flow analysis methods for try/catch, even
  if there were no catch clauses present.

- When calling tryFinallyStatement_finallyBegin for a
  try/catch/finally statement, it was passing in the node associated
  with the original try block (prior to "desugaring").  It needs to
  pass in the node associated with the desugared try block (which
  includes the catches).

Includes a similar fix in the migration engine.

Fixes #39178.

Change-Id: I16440e71d4964b9905fc2316380c8c98f14b13f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123506
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-30 16:30:04 +00:00
Konstantin Shcheglov 4a07d80178 Deprecate ParameterizedType.typeParameters, update typeArguments doc.
Change-Id: I76c02e026c6c566def4f33478ef18f7df9d1d96e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123323
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-10-29 17:39:59 +00:00
Paul Berry 780af0fcfc Flow analysis: promote to "types of interest" on assignment.
This allows so-called "ensure guarded" promotions, e.g.
- `if (x is! int) x = 0;`
- `if (x == null) x = 0;`
- `x ??= 0;`

The latter two are particularly important to prepare for NNBD.

Change-Id: Ib53ca916e6d485945326b19e86f8cfb5b3ee2160
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-29 13:23:59 +00:00
Paul Berry a9fb6b8812 Use TokenType.isIncrementOperator more often.
This is less error prone (and shorter) than checking separately for
PLUS_PLUS and MINUS_MINUS.

Change-Id: I1234d689620ba05dbd878f704a618d5e2e4dea84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123010
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-27 11:09:49 +00:00
Paul Berry 9f25d0e1d8 Flow analysis: don't necessarily clear promotions on assignment.
If the RHS of an assignment is a subtype of the current promoted type
(or one of the previously promoted types), any relevant promotions are
kept.

So for example:

  if (x is int) {
    x = x + 1; // Still an int!
    print(x.isEVen); // ok
  }

This required two significant changes:

- Clients must now tell the flow analysis engine the type of the RHS
  of the assignment.  This required some refactoring in the analyzer,
  because this information wasn't always easily available at the point
  where we were calling flow analysis.

- The flow analysis engine now has to keep track of a "chain" of the
  currently active promotions, so that it can potentially un-do some
  promotions but not others.  This meant that the algorithms for
  "join" and "restrict" had to be reworked.

In a future CL I'll add the ability for assignments to promote to
types that have been previously checked against ("types of interest"),
e.g.:

  if (x is! int) {
    x = 0; // x is now an int!
  }
  // x is now known to be an int because it's promoted in both branches

Change-Id: I63d6c9a2021b045d391b2d9c674e9a2e5f770e62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123003
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-26 20:38:28 +00:00
Paul Berry 696a374b6f Flow analysis: properly handle the fact that ++ and -- are assignments.
Change-Id: Ie54fbf7c7c750457b2750de90c64e8ea32db15d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122730
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 17:57:27 +00:00
Paul Berry 8f5a45c22d Flow analysis: add support for ??=.
Change-Id: I8c99c42cf3a2560d7af3daf27ee316e22a2eb027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122588
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-24 17:57:27 +00:00
Paul Berry b7911e4490 Flow analysis: add support for asserts.
Fixes #38761.

Change-Id: I6cc4adc0383cc56d99fa73ef75f728db0c56063b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122732
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 17:01:33 +00:00
Paul Berry 1bd6e20d76 Flow analysis: simplify the use of AssignedVariables.
Previously, the client was responsible for querying AssignedVariables
to find the variables assigned and captured during constructs like
loops, and passing that information into FlowAnalysis methods.  With
this CL, the client simply passes AssignedVariables into the
FlowAnalysis constructor, and the lookup happens automatically.

Change-Id: Ifbbf8ba8ea0d0f8a31d41244892c8c816eea56dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122731
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 13:00:50 +00:00
Paul Berry 92c69f224b Flow analysis: promote on successful execution of an "as" expression.
Change-Id: I506281ab2dfe23b4b75daf795028fec979006932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122586
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 17:02:37 +00:00
Paul Berry 8e23f76ac7 Flow analysis: properly handle promotion of type parameters.
When promoting a type parameter, we need to create an intersection
type (e.g. "T & int").  Such a type is represented in the analyzer and
the front end as a type parameter type pointing to the same type
variable, but with a different bound.

Change-Id: I1655f9242d913ca958c279cc80c3f6329f6b396d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122581
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-23 15:50:10 +00:00
Paul Berry 0887806796 Flow analysis: introduce TypeOperations.tryPromoteToType method.
Previously, any attempt to promote type A to type B produced type B if
B was a subtype of A, and failed otherwise.  But in order to support
promotion of type parameters, we need the ability to produce a fresh
"intersection type" (e.g. `T & int`).  The new
`TypeOperations.tryPromoteToType method` makes this possible by giving
the client the opportunity to synthesize the new type when necessary.

Change-Id: If671d5d865f38469a878329180c3a1c94e25a42c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122582
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 11:12:21 +00:00
Paul Berry aeede3c1b0 Flow analysis: pass catch variables to tryCatchStatement_catchBegin.
Previously, it was the caller's responsibility to call initialize()
for any variables declared in a catch block.  Now this is done
automatically.

Change-Id: If9c586e12f7d114517476e56e984d16a570648e6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122413
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-22 10:56:54 +00:00
Paul Berry 9579c4bc3c Flow analysis: simplify use of isExpression_end.
Previously, it was the caller's responsibility to determine if the
subexpression of an "is" expression was a read of a promotable
variable.  Now, the caller calls isExpression_end regardless of what
the subexpression is, and flow analysis determines whether promotion
should happen or not.

Change-Id: Ibba689935580d4e9c5ab79e5afb534c173386232
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122411
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-22 10:56:54 +00:00
Paul Berry d0cef92f05 Migration: refactor logic to match up type parameters between function types.
This logic will need to be re-used in the EdgeBuilder.

Change-Id: I042560683903408936b5cfd0910c90ec965cd70e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122306
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-21 07:29:34 +00:00
Paul Berry 22dbc7d748 Migration: FixBuilder support for function expression invocations.
Change-Id: Iad5740dbdc15d8b78a30a87031ab22cf1c171c8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-20 23:23:24 +00:00
Paul Berry 00dc546586 Migration: make more use of .isNullAware throughout migration engine.
Change-Id: Iffc3f1291574450847402571c36fa7881c84de03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121961
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-17 16:09:30 +00:00
Paul Berry 8eb28a4817 Migration: add simple MethodInvocation support to FixBuilder.
Change-Id: Ice76583076a3f38d1cc0f9a3aacbac630a9a97c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-17 16:09:30 +00:00
Paul Berry ca9671f34d Migration: add isUpstreamTriggered getter
It would have been very useful in helping to track down
https://github.com/dart-lang/sdk/issues/38341#issuecomment-542892773
to have this information surfaced through the instrumentation output.

Specifically, it would be nice if the user could hover over a type
annotation that was *not* made nullable due to a propagationStep whose
`reason` was `StateChangeReason.upstream`, and see information about
all the edges for which the `sourceNode` corresponds to that type and
`isUpstreamTriggered` returns `true`.  These are, in effect, the edges
that prevented the type from being marked nullable.

(Note that there's another possible reason a type might not be marked
nullable.  It might be that there are no edges for which the
`destinationNode` corresponds to that type and `isTriggered` returns
`true`.  In this case, the node is indeterminate, so the migration
engine left it as non-nullable because there was no need to make it
nullable).

Change-Id: I9b969201b813496d41f3a373454c2659f683178d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121941
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-17 15:52:11 +00:00
Paul Berry c52ac7b114 Migration: ensure that the target of cascade expressions is visited exactly once.
Fixes #38922.

Change-Id: I451b44055f9039a21e4ab50c473573809bb15c2f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121905
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-17 02:58:01 +00:00
Paul Berry a9d0987476 Migration: generalize FixBuilder's representation of changes to be made to the code.
Change-Id: Id17f70778a4e2c7b5410c02ebee59f1f19e5af9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-16 23:30:16 +00:00
Paul Berry f2dd0465dc Migration: share code for figuring out when an access is null-aware
Change-Id: Id61ebfe16ce277e30a3059f67c250b3a0d9a6b17
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121524
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-14 19:44:10 +00:00
Paul Berry cf7e48bec7 Migration: Handle members of Object properly in FixBuilder.
This code is shared with similar code in EdgeBuilder.

Change-Id: I807269a21472be396e7ba42a89f20efa15eca7fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121523
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-14 19:44:10 +00:00
Paul Berry 878458d7b5 Migration: Add FixBuilder support for property accesses and prefixed identifiers.
Change-Id: I15bbcf6674432c50871aecdd1354c58a2174a6fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121521
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-14 19:44:10 +00:00
Konstantin Shcheglov b74c9f073b Don't use '.type' in EdgeBuilder.
Change-Id: I737b90d07d7894a691fca65aca00924b392c3adb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121662
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-10-14 19:43:00 +00:00
Paul Berry 1e3cbd4344 Migration: Add IndexExpression support to FixBuilder.
Change-Id: I870047d12304c70cfe89e64d4864cc1809b7e4ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121408
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2019-10-12 03:11:03 +00:00
Paul Berry 5594981c2a Migration: add isCompound parameter to FixBuilder.visitAssignmentTarget.
When visiting an assignment target that is an index expression
(`x[y]`) we'll need to know whether we are doing a compound assignment
or not, because this will influence whether the type context for the
index expression (`y`) should come from `operator[]` or `operator[]=`.

So before adding index expression support to FixBuilder, let's add an
`isCompound` boolean to indicate whether the assignment context is a
compound assignment or not.

Change-Id: I26a41544e10ef9c9ba042c1d7862563bd9d18b68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121407
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2019-10-12 03:11:03 +00:00
Paul Berry 13f6d8213b Migration: add FixBuilder support for prefix/postfix expressions.
Change-Id: I62a705af1c8d9944a417d074373aca4c93e99b6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121402
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2019-10-12 03:11:03 +00:00