Commit graph

1164 commits

Author SHA1 Message Date
Paul Berry 1b18e8f5ac Flow analysis: account for initializers of implicitly typed variables.
Previously, initializers of implicitly typed variables did not
contribute to the SSA tracking performed by flow analysis (see
https://github.com/dart-lang/language/issues/1785).  This change fixes
the bug, however the fix is conditioned on the "constructor tearoffs"
language feature to avoid compatibility issues (we don't want someone
to publish a package taking advantage of the fix, without realizing
that it makes their package unusable on older SDKs).

TEST=standard trybots
Bug: https://github.com/dart-lang/language/issues/1785
Change-Id: I1143440c7a9795b059e8f4b84e3f4125cd80732c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211306
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-27 15:01:15 +00:00
Paul Berry e1f0d03ec5 Flow analysis: rework analyzer/CFE handling of initialized variables.
Previously, the analyzer and CFE were responsible for two pieces of
logic that arguably should be in the shared flow analysis engine:

- Deciding whether or not it's necessary to tell flow analysis about
  initializer expressions.

- Deciding whether or not to promote the variable at the time of
  initialization (we do this when the variable is implicitly typed,
  and the initializer is a promoted type variable type).

It's better to just always tell flow analysis about the initializer
expression and let it decide what to do about it.

This paves the way for fixing
https://github.com/dart-lang/language/issues/1785 (which results from
initializer expressions sometimes being ignored when they shouldn't
be), by consolidating the broken logic into the flow_analysis library,
where it will be easy to unit test the fix.

Bug: https://github.com/dart-lang/language/issues/1785
Change-Id: Iec832e92995eb4f8d0c1fbd4e9be6c897e0917b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211180
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-08-27 14:53:06 +00:00
Devon Carew 6465ee4ad8 analyze pkg/nnbd_migration on the bots
Change-Id: I8141ce45531bf5d59d5633400746ffe8af44cbf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210162
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-08-13 20:29:43 +00:00
Paul Berry f66037acce Migration: add support for Angular's @ViewChild() and @ContentChild() annotations.
Bug: https://github.com/dart-lang/sdk/issues/45661
Change-Id: Ie77d720677fb032585e17fe13358afe597e702bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209820
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-11 01:55:41 +00:00
Paul Berry 4d0dc2ea8a Migration: add support for Angular's @Optional() annotation.
Bug: https://github.com/dart-lang/sdk/issues/45661
Change-Id: I6c8c87c2a0d26dc8053ef66961a96e03cf5a2582
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209780
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-10 21:32:51 +00:00
Paul Berry eaf75d19ff Move shouldIgnoreUndefined logic into LibraryElementImpl.
This logic was previously in LibraryScope and ScopeExtension.  It
really isn't related to scopes, though, since all it does is to look
through the library's imports and parts.  (The only use it made of
scopes was to locate the library element).

Separating this code from scopes will facilitate some other changes
I'm working on to streamline the use of scopes in the analyzer.

Change-Id: Ic45e3382628a433a96cc7ecf751b4df5d681b42a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/208522
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-02 14:29:20 +00:00
Paul Berry 8d6aba5698 Analyzer: make CompoundAssignmentExpression implement Expression.
This is reasonable, since every CompoundAssignmentExpression *is* an
expression, and it allows clients (such as the migration engine) to
avoid nuisance casts.

Change-Id: Ic6f0fc88672248e2de4410a0f1c16b7f476fa55c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207360
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-20 13:42:00 +00:00
Brian Wilkerson 9db372e6f4 Make Location.endLine and Location.endColumn optional fields in the protocol
In https://dart-review.googlesource.com/c/sdk/+/191862 we added two new
required fields to `Location`. Unfortunately this was a breaking change
because plugins using an older version of the `analyzer_plugin` produce
location objects without those fields, leading to deserialization failures.

This CL makes those fields optional in order to fix the deserialization
issue.

Unfortunately, the `analyzer_plugin` package was published after the
required fields were added. Making them optional is a breaking change
because the constructor parameters go from being positional to being
named parameters.

We also neglected to update the version number of the protocol as part
of the previous CL. Technically this is also a breaking change for clients
of the analysis server, but given that they had no way to test to see
whether these fields existed they would need to have been written as if
the fields were optional in order to reference them at all, so I think
that from a practical standpoint it isn't a breaking change. That does,
however, raise the question of whether we should increment the version
numbers as part of this CL.

Change-Id: I35fc1f8e950669a3d8dd33cee6b81890261b5c47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206942
Reviewed-by: Danny Tuppeny <danny@tuppeny.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2021-07-15 17:35:55 +00:00
Paul Berry 066ec3a44a Migration: discard @nullable annotations on property accessors.
The migration tool already correctly infers nullability or
non-nullability based on the code generated by the built_value
package.  However, post-migration, code should no longer use
built_value's `@nullable` annotation, since the built_value package
gets its signal from the `?` type suffix instead.

The migration tool already has the ability to remove annotations in
certain rare circumstances; it's a relatively trivial matter to extend
it to remove `@nullable` annotations when appropriate.

Note that we don't just remove any `@nullable` annotation; we only
remove those annotations that resolve to the `nullable` constant
defined in the `built_value` package.

Fixes #43878.

Bug: https://github.com/dart-lang/sdk/issues/43878
Change-Id: I39c9b5e6fe4cd149b6d9549cd785d7b87c3185d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206940
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-07-15 16:22:09 +00:00
Paul Berry e98091010e Migration: fix handling of unresolved field formal parameters.
Change-Id: I67d3472974657618afa88d7feafae1eaf8250e43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/207040
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-07-15 16:22:09 +00:00
Paul Berry e60a3c5cd8 Migration: Fix a corner case crash when removing all metadata nodes.
Previously, when removing all metadata nodes from code such as this:

    f({
      @removeMe
      int? i}) {}

If the node(s) being removed occupied entire lines (as they do in this
example), the logic for trying to decide whether to collapse together
empty `{}`, `[]`, or `()` would get confused by the fact that the text
being removed began at the start of the line, even though the parent
AST node (`@removeMe int? i`) didn't begin until partway through the
line; this would cause an assertion failure (or, if assertions were
disabled, an out-of-range error).

As of yet, this has never been a problem in practice, because the only
circumstance in which the migration engine removes metadata is when
adding other metadata (and thus the logic for trying to collapse
together empty `{}`, `[]` or `()` doesn't trigger).  But in a future
CL I'll be adding logic that *can* remove the only metadata and
trigger this problem.  So to prepare for that, this CL fixes the
out-of-range problem.

Change-Id: Ie2d050d656512a7c725752427eaaec1c087f3c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-15 11:57:49 +00:00
Paul Berry 82f2906764 Migration: properly handle non-nullable built_value getters
This change makes the migration tool understand that the method
`BuiltValueNullFieldError.checkNotNull` expresses non-null intent.
Since the built_value code generator calls this method from generated
built_value constructors, this is sufficient to ensure that built
value getters that lack the `@nullable` annotation will be treated by
the migration tool as non-nullable.

Bug: https://github.com/dart-lang/sdk/issues/43878
Change-Id: I37a9ce584a10d2a1bb27da92f3f664632547f6ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206881
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-07-15 11:57:02 +00:00
Paul Berry 0e7f5d9d84 Migration: propagate non-null intent to constructor field formal parameters.
Previously, when the migration tool encountered code like this:

    class C {
      int i;
      C(this.i) {
        assert(i != null);
      }
    }

the assertion would not confer non-null intent on the `i` parameter of
the `C` constructor, because the `i` referred to in the assert
statement is technically the `i` field, not the `i` parameter (and we
do not propagate non-null intent through fields).

With this CL, the migration tool treats field references in
constructors to refer to field formal parameters when possible; even
though this technically does not exactly conform to Dart semantics, it
captures user intent far better; the only cases where this would
produce an incorrect result are when the field is reassigned and then
used in the constructor; such cases are quite rare and should be easy
for the user to compensate for using migration hints when necessary.

Change-Id: I4c624dab051e62fa29f103ad08ce2ce9c5137663
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206880
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-07-15 11:57:02 +00:00
Paul Berry 054426c9c5 Migration: Remove _ScopedLocalSet class.
This class wasn't really necessary; it was just a container for a few
extra methods used only by the EdgeBuilder.  By moving those methods
to the EdgeBuilder and removing the _ScopedLocalSet class, we open up
the possibility of expanding the capabilities of those methods to take
advantage of other information the EdgeBuilder has access to.  (I will
do this in follow-up CLs).

No functional change.

Change-Id: I7cf19b8cf81db0413f4a9e747d46fb619d5eac4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206840
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-14 17:41:50 +00:00
Paul Berry 0a064b9ed7 Migration: make the element type of _ScopedLocalSet non-nullable.
Previously, _ScopedLocalSet extended ScopedSet<Element?>, but this was
unnecessary; it was an artifact of the fact that the migration tool
was migrated to null safety in a conservative way.  We know that all
elements of a _ScopedLocalSet are non-null elements because they all
represent actual variables declared in the user's code.

Change-Id: I4d0c86997ff3c783cee6ea84cff80363e14c3060
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206670
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-07-14 16:30:30 +00:00
Konstantin Shcheglov 79327c9f05 Make ResolvedUnitResult.content/unit non-nullable.
Change-Id: Ia79567d248f2c91290bfdf8204ea7e9f3dc85fa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206668
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-14 02:33:10 +00:00
Konstantin Shcheglov cac96f7f8d Rename AnalysisSession.getXyz2() into getXyz().
Change-Id: Ia76aafc6a1190dcdca026097c364270389f2860a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206565
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-12 22:42:58 +00:00
Konstantin Shcheglov a9618ac795 Make ResolvedLibraryResult.element/units non-nullable.
Change-Id: Ie20c2363b43555573843c038c15c0d55bcf39579
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206563
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-12 20:48:37 +00:00
Konstantin Shcheglov 672d66cea0 Make AnalysisResult.path non-nullable.
Change-Id: I861643f6c5493b6990c0bacddd81643aaba8e368
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/206560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2021-07-12 18:21:11 +00:00
Paul Berry fcb5c4f4b6 Migration: stop explicitly opting generated code into null safety.
This is no longer needed now that the whole migration engine has null
safety enabled.

Change-Id: I834bfb18f9b4d838c0cc933acb6977566bc1643a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204484
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-23 23:35:47 +00:00
Paul Berry 730cbcbe6e Fix hints and lints after migration of the migration tool.
Change-Id: I90ac7e88686ba6db9b9e64538663ae2044638894
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204483
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-23 23:35:47 +00:00
Paul Berry 768104377b Fix warnings after migration of the migration tool.
Change-Id: Ia1c1f71809ce8d843ee2ed7d99e530ace83e18ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204482
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-23 23:35:47 +00:00
Paul Berry 6594ded7d9 Run the migration tool on itself.
Change-Id: Ifbdf1c33cc359519fdcf2637d50a9e4d3b054af7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204481
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-23 23:35:47 +00:00
Paul Berry dcad8c94ef Hints etc. to prep for migrating the migration tool
This change adds just enough migration hints so that I can run the
migration tool on itself and get reasonable results.  Most of the
hints are just marking a few types as nullable or non-nullable that
the migration tool isn't able to correctly infer by itself.  In a few
circumstances I've had to make a type explicit that was previously
inferred, so that I could mark it as nullable.  In a few other
circumstances I've had to add `/*!*/` after an expression to let the
migration tool know that the expression should be null checked.

Note that unlike most of the rest of the Dart SDK, the migration tool
is not expected to be a long term part of the Dart ecosystem, since
the whole point of it is to help people migrate their code to null
safety.  It's not likely to receive a lot more maintenance, and it
will likely be removed sometime around the time of Dart 3.0 once
people stop needing it.  Accordingly, I've tried to err on the side of
liberally allowing types to be nullable where possible.  Although this
means that we will wind up with more null checks in the final result,
it makes the migration process a lot easier and substantially reduces
the risk of introducing bugs during the migration process.

Change-Id: Ia348a09e94d22d83c2c15215ca7ddf5a5a4d05f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204480
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-23 23:20:57 +00:00
Paul Berry c041afad9f Decouple the migration tool from package:dartdev so it can be migrated.
In order to migrate the migration tool to null safety, it can't have a
dependency on `package:dartdev`, because `package:dartdev` isn't
migrated yet.  (This is a problem because once the migration tool's
tests have been migrated to null safety, they will require the
transitive closure of all the packages they depend on to also be
migrated).

Fortunately, it's quite easy to change the migration tool so that it
doesn't depend on `package:dartdev`; we only need to move the class
`MigrateCommand` from `package:nnbd_migration` to `package:dartdev`.

To make this work, we have to move the constant `migrationGuideLink`
from `MigrateCommand` to `MigrationCli`, and make the method
`MigrationCli._defineOptions` public.

Change-Id: Ie1ce8db0e8245e98bbb72facddd723300816340e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204540
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-23 22:57:21 +00:00
Paul Berry 02e82dae37 Migration: fix formatting in nullability_node.dart
Change-Id: If81aa896e9774001a0c3a2d1d661bc58c41b9cdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204425
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-21 22:32:00 +00:00
Paul Berry ff058cffa6 Migration: Migrate generated file resources.g.dart to null safety.
Change-Id: Ia7db1e886c66601c47f251fa160001e743302f09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204423
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-21 19:18:10 +00:00
Paul Berry 1641a4bcfb Remove unused import
This import was accidentally included in
https://dart-review.googlesource.com/c/sdk/+/204180 but it wasn't
needed.

Change-Id: I11d70c49aba784e907bb3d2d235bedb7570489c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204422
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-21 18:32:00 +00:00
Paul Berry 497f1020a8 Migration: fully delete the postmortem tool.
I removed the postmortem functionality in
203d0ed789 but instead of removing the
postmortem tool itself, I merely removed the body of its `main`
method.  This CL finishes the removal.

Change-Id: I525afe40ab3b69b81edc28b0fdded06fed5710c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204320
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-21 14:29:09 +00:00
Paul Berry 62f72311ae Migration: make API tests fail if there's an unexpected error.
I've recently wasted a lot of time tracking down strange behaviors
that resulted from inadvertenly writing a migration API test
containing a static error.  Failing the test early if there's an error
should avoid that problem in the future.

Change-Id: Idc9d84901a517ce9555fa3180f5c669aea449ea5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204180
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-19 16:58:04 +00:00
Paul Berry 685a0782b6 Remove unused argument typeArguments from MigrationResolutionHooksImpl._transformCollectionElements.
Change-Id: I6c66b118d24419cae63cf0c6ad93d395c89b52cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204300
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-18 22:17:46 +00:00
Paul Berry 0ab30d074d Remove InstrumentationInformation.nodeInformation and related code.
Data was being stored in this field but never read.

Change-Id: Ida763236b71401ba8ddd0ec5bf4880e7cc657d6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204281
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-18 22:17:46 +00:00
Paul Berry a093bbcde5 Sort declarations in instrumentation_listener.dart
Change-Id: I8656446025c790b45c0a6ba2d128be24b7d0988b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204280
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-18 22:17:46 +00:00
Paul Berry acc80e9374 Migration: fix handling of optional parameters to factory redirecting constructors.
Factory redirecting constructors inherit their parameter default
values from the constructors they redirect to, so lack of a default
value on one of their optional parameters doesn't mean it has to be
nullable.

Change-Id: I9572f4ac954e76a391c65515b30bdf613a78774c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203380
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-18 20:19:25 +00:00
Paul Berry 495425a546 Migration: accept prefix /*required*/ hint when present.
Previously, such a hint would influence the nullability graph, which
would usually cause the migration tool to decide that a `required`
keyword was necessary.  However, this didn't always work (for example
if the type was nullable, the hint would be ignored).  Also, even when
the hint was accepted, the tool would insert a `required` keyword and
leave the hint; now it converts the hint into the keyword by dropping
the `/*` and `*/`.

Change-Id: I0620ceaef3fd5a13cfddf18c15e12e50e7574d73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/204062
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-18 16:14:53 +00:00
Paul Berry 25c09d052e Migration: remove unnecessary EdgeBuilder._requiredHintedParameters
The only elements that were ever stored in this set were parameter
elements, and the only time this field was used was in the condition
`... && !_requiredHintedParameters.contains(staticElement) &&
!_flowAnalysis.isAssigned(staticElement)`.  However, flow analysis
considers parameter elements to always be assigned.  Therefore, if
`!_flowAnalysis.isAssigned(staticElement)` is satisfied, then
`!_flowAnalysis.isAssigned(staticElement)` must also be true.  So
testing the two of them is redundant.  And therefore we can remove
tracking of EdgeBuilder._requiredHintedParameters entirely without
affecting behavior.

The reason I want to do this is because we had a confusing
inconsistency in how we were populating
EdgeBuilder._requiredHintedParameters: we were only tracking
parameters whose hints took the form `/*required*/`; we were not
tracking parameters whose hints took the form `@required`.  It seems
like since the whole variable has no effect, it's better to just
remove it rather than fix the inconsistency.

Change-Id: I3b36317e60e08b0577c504a773428b85fb9cdce1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203825
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-17 22:50:21 +00:00
Paul Berry 203d0ed789 Migration: remove postportem file capability
We used these "post-mortem" files for some early debugging, but they
were never useful enough for us to get around to hooking up a way for
the user to enable them.  At this point, keeping around the capability
doesn't buy us anything, and adds to maintenance burden.

Change-Id: Ib25a98187b63cf785941a1b750615455dfea237c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/203800
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-16 16:34:37 +00:00
Paul Berry 9a83a75a10 Migration: fix handling of /*!*/ comments in is/as expressions.
Previously, the migration tool had a small amount of special case
logic in `EdgeBuilder._dispatch` to ensure that if an `as`
expression's type was annotated with `/*!*/`, that `/*!*/` wouldn't be
misinterpreted as also applying to the `as` expression itself (causing
a `!` operator to be inserted).  This logic wasn't sufficiently
general; it failed to handle `is` expressions (which can run into the
same issue), and it failed to handle situations where the `is` or `as`
expression was at the end of a larger expression (e.g. `y = x as
T/*!*/;`).

This change removes the special case logic and replaces it with a more
general-purpose mechanism: when visiting any type name, if it ends in
a `/*!*/`, the edge builder stores information about it in the
`_nullCheckHints` field.  This ensures that when visiting an
expression ending in that type name, the `/*!*/` will be ignored
(since `EdgeBuilder._handleNullCheckHint` skips any hints that are
already stored in that field).  This ensures that we properly handle
both `is` and `as` expressions, as well as larger expressions that
contain them.

Change-Id: I2b902ef809b4cc5eb8b493fa4405c0f0c8c10a96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202261
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-06-03 17:39:47 +00:00
Paul Berry 4b5c275d2c Sort api_test.dart
Change-Id: I1beb4c553b0e9b03ce9c37d3507ec33ed44269ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/202260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-06-03 17:39:47 +00:00
Ben Konyi f99c918ee8 [ CLI ] Improve consistency of help messages between commands
Updated some formatting and added '[vm-options]' to relevant commands
when '--verbose' is provided.

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

Change-Id: Ic4ccd81290ccf4000b0bce7d5dba63c469fb4c20
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/200283
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2021-05-17 21:20:22 +00:00
Devon Carew 15187a692d [dartdev] refactor the 'dart migrate' package:args command
Change-Id: Id9f2a5289b75bb26258925f7686d32f4f6a0eb51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/199760
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2021-05-14 15:30:18 +00:00
Paul Berry 1c86b2f5f6 Migration: tolerate relative imports into lib.
Prior to this fix, if the user's package had a relative import from
outside `lib` to inside `lib` (e.g. from `test` to `lib`), the
migration tool would regard the imported file as being reached via a
`file:` URI.  This caused it to get confused and complain that the
user had a dependency on unmigrated code (this happened because the
check for dependency on unmigrated code excluded the user's files via
their canonical URIs, and files inside `lib` use `package:` for their
canonical URIs).

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

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

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

Fixes #45780.

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

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

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

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

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

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

TEST=CL contains no code changes.

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

Fixes #45571.

Bug: https://github.com/dart-lang/sdk/issues/45571
Change-Id: Id11584a1d8b7a6b35127ad828d37b3ef837a5e65
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194009
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-04-06 05:12:56 +00:00