Commit graph

1289 commits

Author SHA1 Message Date
Paul Berry dc059d763b Migration: Pass ExpressionChecks to _checkAssignment instead of the raw expression.
This paves the way for a follow-up CL that will introduce a more
general notion of the "origin" of an edge (of which ExpressionChecks
will be just one kind of origin).

Change-Id: I76ee12679d881ef95a4ba17a224fe85ecf6b589f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-06-17 21:06:21 +00:00
Brian Wilkerson 8461cc6f5b Support for list literals with type arguments
Change-Id: I7a661d83335b7d4c4ef2221af3eb31c865e2f9dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106386
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-17 20:55:11 +00:00
Brian Wilkerson 2164bcefdb Add support for await expressions
Change-Id: I36c1bad75a0f6981715e621c09df1befef38061a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106166
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-17 16:58:51 +00:00
Brian Wilkerson 071a99bfbe Add support for super expressions
Change-Id: I7d78810ca7fe8f669370803f2dd8146379ca2f7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106164
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-17 16:15:54 +00:00
Paul Berry 58664602a5 Change NullabilityGraph.propagate to return a list of unsatisfied edges.
In follow-up CLs this should allow us to simplify the generation of
fixes (since each fix is associated with one or more unsatisfied
edges) and to streamline tests.

Change-Id: I997f704aac41f270756adcdf8d382fb2263273eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106180
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-15 12:55:00 +00:00
Brian Wilkerson 047bacc94c Add support for symbol literals
Change-Id: I273b2290b8d4d2e0948fac1962d02efc70e7813e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106163
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-14 22:13:40 +00:00
Brian Wilkerson 9bb678f88b Add support for is expressions
Change-Id: I3be70d83b03a4d00a68070fb03ba2ab989880a9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106161
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-14 21:43:50 +00:00
Brian Wilkerson f56df4a251 Add support for double literals
Change-Id: I08ea12bb0213272b192d063fd3699b2495912077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106140
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-14 19:57:26 +00:00
Paul Berry fc5eb09cb9 Migration: remove getUpstreamNodes
This method was unnecessary--the same functionality can be provided
more efficiently by getUpstreamEdges.

Also fixed a doc comment error in getUpstreamEdges.

Change-Id: I44560eced353b57e00b06e57c8c628de79d689e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106121
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-14 18:31:57 +00:00
Brian Wilkerson 1e454a1c1b Add some missing visit methods from the visitors
I'll start implementing them and adding tests in future CLs.

Change-Id: Ic8cb5ed9bd00f05232869d7f4c585daa5d5ab4c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106122
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-14 18:03:37 +00:00
Brian Wilkerson dcc85a6594 Fix exception thrown in ConditionalModification
Change-Id: I6e60bd74bc55cafca86a64a721455e0ed465a357
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106101
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-14 17:13:37 +00:00
Brian Wilkerson fb85d41c08 Catch another exception earlier in the code
Change-Id: Ia9fdca760c4c0838cdb6bb31c00f296fbf21cbac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106102
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-14 16:02:37 +00:00
Brian Wilkerson 25292abc1d Add support for boolean negation
Change-Id: Idae8d8dbedacdd0004dff3afad2d736b3a652466
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105972
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-13 23:02:57 +00:00
Brian Wilkerson a19611b079 Improve test coverage for constructor parameters
Change-Id: Ia1a803bd52e94e15696c60c77938fd2f5c08bdaf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105981
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-06-13 22:20:26 +00:00
Brian Wilkerson e9f17ae8e8 Convert some NPEs into explicit throws and add the missing visit methods discovered by doing so
Change-Id: I0613614168a7373a460d05cf8470f9b59264de0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105970
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-13 18:51:44 +00:00
Brian Wilkerson 9676ca0ff9 Support constructor invocations with arguments
Change-Id: I2d537121efd29f051d8f533c6f58e0ad10835301
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105964
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-13 18:29:10 +00:00
Paul Berry 9d3afa537e Compute parameters before calling DecoratedType constructors.
This will allow me to put stronger assertions in the DecoratedType
constructor in a follow-up CL.

Change-Id: I375ae2b33c2f14948d9fedbdfbc000b8a1057b00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105963
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-13 17:06:16 +00:00
Paul Berry dad07f8156 Migration: Fix return value of GraphBuilder.visitTypeName.
The return value of the GraphBuilder visit methods should always be
the type of the AST node assuming it's used as an expression.  When a
type name is used as an expression, its type is always a non-null
reference to the built-in type `Type`.

(Note: this wasn't causing any failures, but fixing it will allow me
to add stronger assertions in a follow-up CL.)

Change-Id: I62c72dcfc6c0f12f8d8a1a7de34a1d3f94c5e4f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105962
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-13 16:11:30 +00:00
Paul Berry cba75a1d1d Migration: fix accidental hardcoded 0 in GraphBuilder.visitTypeName
Change-Id: I4d75bc286fe8d5dfe063b30525a99dacc96b4ec6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105961
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-13 15:21:50 +00:00
Paul Berry e5f069b5dd Migration: add missing type annotation
Change-Id: Ie219297a4ffe203e0b15157471a2a59f1b1029a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105960
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-13 15:21:50 +00:00
Brian Wilkerson 52ae429a9e Add some minimal support for instance creation expressions
Change-Id: I7184b8b5955d61e0d1452a8ff071aaab8ceb5dce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105728
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-12 23:47:39 +00:00
Paul Berry eec587e97d Migration: address a more complex case of instantiate-to-bounds.
Change-Id: I8a7d5e2e4189c3d910077ad4ec88e6c4e384dc25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105731
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-12 23:03:57 +00:00
Paul Berry f2cc27ffbf Migration: preliminary support for interface types without type parameters.
I'll build on this in future CLs to address more complex cases, where
the type is instantiated to a bound.

Fixes #37213.

Change-Id: I1e23c5599557ef17177483222f15b1a7985b9ca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105726
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-12 23:03:57 +00:00
Paul Berry 3f83aeb493 Migration: add the ability to "union" nullability nodes.
This will simplify some situations where nullability migration would
otherwise have to visit the source code in a very careful order.  For
example, when analyzing top level fields undergoing type inference, we
can simply create a node for the nullability of each top level field,
and then later use the "union" operation to hook up those nodes to the
nodes resulting from analyzing their initializers.  Without the union
operation, we would have to be careful to visit the top level fields
in dependency order.

Change-Id: I3b07e1abccc5b1c9f1c7c9fa7b13fb6af60c07d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105800
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-12 20:10:24 +00:00
Paul Berry 0b5e37a429 Migration: Make always/never instance fields of the nullability graph.
Previously, they were static, which made them easier to access, but
made it difficult to track their edges (because we couldn't safely
mutate them, so we had to store their edges in special fields of
NullabilityGraph).  Now that we're passing NullabilityGraph all over
the place anyhow, there's no benefit to making them static anymore.

Change-Id: Ia3e7d32ae479f40f505621e5d6df04060e39b1c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105723
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-06-12 20:10:24 +00:00
Paul Berry b385528fee Migration: Write unit tests for NullabilityGraph.
Change-Id: I7d3ab1bde98ff28203dc73d61ecdc77e8fed25f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105682
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-12 13:34:57 +00:00
Paul Berry c286d5a549 Separate testing methods from the rest of NullabilityGraph
So that we don't accidentally start to use them elsewhere in the
migration engine.

Change-Id: Iee290f9fc8761c952a2aadb1f4f6bb7bfe061a3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105700
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-12 13:34:57 +00:00
Brian Wilkerson 97dc7f4482 Support constructor declarations (issue 37196)
Change-Id: I276e897a02c999c7c1ab08d12f51e5bd9676bb0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105543
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 20:56:36 +00:00
Brian Wilkerson ed9d185a9e Top-level getters do not have parameters
Change-Id: If8e079987f957538286afed162073fe4f323dea2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105469
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 20:36:16 +00:00
Paul Berry 5ca5a53f64 Migration: Add support for generic function types.
Fixes #37212.

Change-Id: I3dfe0afa32564b9e4762f3410f5c44ea42d6d004
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105467
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-10 20:29:59 +00:00
Paul Berry c2696591a6 Migration: Add more support for dynamic, clean up handling of void.
Change-Id: I0e83f614e58bcdbb4b1a37d20da4d97587d6bd5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105466
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 20:29:59 +00:00
Paul Berry 8b17b2e143 Migration: add support for null-aware accesses.
Change-Id: Ie034c0410e667f2e55fd2b9d9e9b2b3b3726de30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105465
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-06-10 19:53:06 +00:00
Paul Berry 881a2e9e48 Migration: remove unnecessary constructor argument
Change-Id: Ic544c37070d6ac3b874dc1a34d1709cf0949ff70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105441
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 18:11:30 +00:00
Paul Berry eba533dcd1 Migration: Clean up handling of LUB and substitution nodes.
Previously we created artifical edges from a LUB node's components to
the LUB node; now the nullability propagation algorithm understands
how to propagate nullability downstream through LUB and substitution
nodes, so no artificial edges are needed.

Change-Id: Ib2fef14c3dcd58a013ad8e057fd55597a1deb4fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105402
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 18:11:30 +00:00
Paul Berry 0a0927de9c Migration: Separate the implementation from the NNBD migration engine's public API.
Change-Id: I0ea000b9068661d4e9122414320202ebd4f8563b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105413
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 17:10:45 +00:00
Paul Berry 575a6424c3 Migration: Remove transitional API
Change-Id: I9853b7577ba4b39bf1d51f7d03ba3c2d6499e79b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105412
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 16:18:05 +00:00
Paul Berry e23b00745f Migration: Move classes out of transitional_api.dart
This paves the way for removing the transitional API altogether.

Change-Id: I95181b04173d3439d278f898ae3b5ec574108b32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105411
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 15:13:23 +00:00
Paul Berry 47865b7643 Migration: remove unused field Variables._graph.
It wasn't detected by the "unused field" hint because there is another
field in the same file with the same name that *is* used
(NullabilityMigration._graph).

Change-Id: I955f30d010ddaa2d218f61daf32978d391182708
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105410
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-10 15:13:23 +00:00
Paul Berry 51046368c5 Move NNBD migration tool to a fresh package.
This gives us more flexibility for how we want to publish and deploy
the tool.  We now have the option, for example, of making a command
line app that invokes the tool and does not depend on analysis_server.

Note that some testing infrastructure had to be duplicated.  I plan to
consolidate this infrastructure in follow-up CLs.

Change-Id: I046506bc2bb5c3e467e15885f198ee0632351ee9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/105463
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-09 17:45:35 +00:00