Commit graph

1289 commits

Author SHA1 Message Date
Konstantin Shcheglov 664c021374 Deprecate xyz2 in elements.
Change-Id: I0dbf25882cf66670ce2d69dd22aceb053be9feb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265182
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-10-21 22:07:47 +00:00
Sam Rawlins e7c590b137 Make some bool fields in nullability_node non-nullable
Change-Id: If50538f4e4c189d45af0a2c22e7a6a19a29c7f68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265080
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2022-10-21 13:23:57 +00:00
Paul Berry 5349d8c602 Migration: account for generic bounds when determining whether null checks are necessary.
Previously, if a variable with a generic type was null-checked, and
the migration engine did not add a question mark to the type of the
variable itself, e.g.:

    f<T extends Object?>(T x) {
      if (x == null) { ... }
    }

Then the migration tool would erroneously consider the null check
unnecessary.  It failed to account for the fact that the bound on the
generic type might be nullable.

This change fixes the tool so that it now properly accounts for the
bound on the generic type variable.

Bug: https://b.corp.google.com/issues/247496662
Change-Id: I2b131e75b7e3fc5db0b668f1064340d404442c82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264501
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-10-19 19:44:20 +00:00
Sam Rawlins c3fb570105 Add "Add 'late' hint" feature
Tested with:

* top-level variables
* local variables
* instance and static fields declared in classes and mixins (enhanced enums are not supported pre-null safety)

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

Change-Id: I8a89668fffe64fff508d0aeb36aaebef5c84f223
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263460
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-10-17 15:24:57 +00:00
Paul Berry ef24f4c915 Migration: make DecoratedType.node non-nullable.
Change-Id: I1bbaf596c26cd059da693f75483f16b4f621b4e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264380
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-10-16 23:42:52 +00:00
Sam Rawlins 8d998a89a2 Update migration tool README
Change-Id: I16349a7399d735a6edf8615570f4c783a98e8276
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263461
Reviewed-by: Paul Berry <paulberry@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-10-13 19:00:25 +00:00
Konstantin Shcheglov 683e2419da Deprecate 'DartType.element2' use 'element' instead.
Change-Id: I6986a058616db489987789cfab09d53a450e3ab5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262666
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-10-05 16:30:09 +00:00
Konstantin Shcheglov fcc9473dab Deprecate CatchClause.exceptionParameter2/stackTraceParameter2
Change-Id: I3f0ae9367f35fe514a125cb0f06ccbdc8fa0dc18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262502
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-10-04 15:58:11 +00:00
Paul Berry 175385825a Migration: clean up handling of type substitutions.
Previously, when the migration tool needed to change one type variable
to another during a substitution, it created a DecortedType to
represent the substitution using
`DecoratedType._forTypeParameterSubstitution`.  This was problematic
because the resulting DecoratedType had a null nullability `node`.
This in turn forced nearly every reference to `DecoratedType.node` to
be followed by a `!` operator.

With this change, we now have a new base class, `SubstitutedType`,
which can either be a `DecoratedType` (representing a fully general
substitution) or a `_TypeVariableReplacement` (representing a simple
change from one type variable to another).  This paves the way for a
follow-up CL that will make `DecoratedType.node` non-nullable.

Change-Id: I7fdaef57994c7678ecd517ab4fe84d00f0d81424
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261941
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-09-30 13:14:31 +00:00
Konstantin Shcheglov 745d0ff64a Deprecate 'Element.enclosingElement3', use 'enclosingElement'.
Change-Id: I6f4fd7e8c0f071bde10cb5e57ed6195ae517e575
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261221
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-09-26 23:58:14 +00:00
Konstantin Shcheglov 44316060f1 Deprecate 'get declaredElement2', use 'get declaredElement' instead.
Change-Id: Ida7a9c2ac35943aed2d75f81f98ce7056b616aee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260741
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-09-23 20:05:29 +00:00
Paul Berry 043f18f843 Flow analysis: use a callback to check if a property is promotable.
Previously we expected the client to provide a set of promotable
fields, which worked well for testing.  But using a callback gives the
client more flexibility (e.g. it would allow field promotability to be
computed on demand based on other data).

Bug: https://github.com/dart-lang/language/issues/2020
Change-Id: I40683a4c19a17147e86f0faa1339aa025da35229
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256962
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-09-22 13:09:07 +00:00
Paul Berry 872e4c5696 Migration: properly handle accesses to getters in mixins.
Bug: https://b.corp.google.com/issues/246998513
Change-Id: I8ca1fe87f256dbf4f31fca9bd3f555d1def4bb3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260446
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-09-22 12:26:17 +00:00
Konstantin Shcheglov e03170035a Deprecate 'get name2', use 'get name' instead.
Change-Id: Iee8ef5fb6700d96c857a22a99dc61dac3da88572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260443
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-09-22 02:22:47 +00:00
Paul Berry 7db67f3353 Migration: properly handle a field overriding a field in a mixin.
Bug: https://b.corp.google.com/issues/246998513
Change-Id: Idcf496ee2957e80592fe22a016ca206b11274778
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259659
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-09-19 17:11:51 +00:00
Ahmed Ashour 5fe480b788 Fix typos
Fix #49864

TEST=ci

Change-Id: I9a7e06d604cd0b4f56f2ac229ab3fc9f01cb9d76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2022-09-16 19:35:00 +00:00
Paul Berry 22a405bf8a Add a test case for #44394
This issue (Migration tool null safety detection fails when tests use
path imports) was reported in December of 2020 and I can't reproduce
it.  I believe there have been changes in analyzer package resolution
since then, aimed precisely at helping users who use this sort of
improper path import.  So it is likely that those changes fixed this
bug.

I'm adding a test case to ensure that the bug isn't accidentally
un-fixed by future changes.

Bug: https://github.com/dart-lang/sdk/issues/44394
Change-Id: I81490e545aa41196c3c69bc4d74cd481079d59ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259200
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-09-14 16:10:42 +00:00
Paul Berry 466494f5be Shared type analysis: API adjustments for analyzer and CFE
I've begun prototyping what it might look like to integrate the
current shared type analysis functionality with the analyzer and CFE,
and I've discovered some API improvements that are needed:

- The shared logic now handles the possibility that switch cases that
  share a body have been merged prior to type analysis (because the
  CFE merges them during parsing), in addition to the pre-existing
  functionality which assumed that switch case merging had to be done
  in the shared logic.

- The shared logic now returns several pieces of information as the
  result of a call to `analyzeSwitchStatement`: whether the switch
  statement had a `default` clause, whether it was exhaustive, whether
  the last case body terminates, and the type of the scrutinee.  These
  are all needed by the CFE.

- The shared logic now allows `TypeAnalyzer.errors` to be `null`,
  indicating that no errors should be reported.  This reflects how
  errors are suppressed during top level inference in the CFE.

- If a switch case lacks a `when` clause, this is reported by calling
  `handleNoWhen` rather than passing a boolean to `handleCaseHead`.

- The shared logic now reports the appropriate error when a case
  constant doesn't properly match the scrutinee's static type.

- Information about case labels is now delivered to flow analysis via
  `switchStatement_endAlternatives` rather than
  `switchStatement_beginCase`.  This made it possible to rewrite the
  shared `analyzeSwitchStatement` method in a way that requires less
  bookkeeping, because it no longer has to peek ahead to look for
  labels associated with a given case body.

- `TypeAnalyzer.analyzeExpression` is now responsible for
  understanding that "no context" and a context of `dynamic` should
  both be coalesced to `?`.  The analyzer does this (although it's not
  100% why), and it's definitely "business logic" that eventually
  belongs in the shared type analyzer.

- `TypeAnalyzer.analyzeSwitchExpression` and
  `TypeAnalyzer.analyzeSwitchStatement` no longer receive a list of
  ExpressionCaseInfo / StatementCaseInfo objects describing the cases;
  instead they query for them using a callback.  This reduces the
  lifetime of the ExpressionCaseInfo / StatementCaseInfo objects.  In
  the future, when we have record support, we could replace these
  objects with records, which would then be passed on the stack,
  avoiding any allocations.

- A new hook, `handleSwitchScrutinee`, is called right after visiting
  the "scrutinee" expression of a switch expression or switch
  statement.  This hook is needed by the analyzer to compute
  exhaustiveness.  In a future CL, I hope to move exhaustiveness
  analysis into the shared code as well, which should make this hook
  unnecessary.

- `TypeAnalyzer.analyzeSwitchStatement` now reports an error if a
  switch case completes normally and pattern support is not enabled.

- The test class `_MiniAstTypeAnalyzer` no longer overrides
  `analyzeExpression` to provide a default context type; instead,
  every call to `analyzeExpression` that didn't previously provide a
  context now provides a context of `?`.  Note that not all of these
  are correct, but they are close enough for the unit tests we have
  today.  I plan to fix them in future CLs as I replace this logic
  with shared logic.

- The hook `handleVariablePattern` is now always provided with a
  static type.  Previously, it was only provided with a static type if
  this was the first time the variable was bound in the pattern.

Change-Id: I70e3c5468312a9329fcf4ad2e13749a32d2418e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257487
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-09-12 13:55:37 +00:00
Konstantin Shcheglov 6f0fe880c4 Breaking changes for analyzer version 5.0.0
Reland of https://dart-review.googlesource.com/c/sdk/+/243164

Change-Id: I5167844ea1001f026cf8d9b82465a79f560d188d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257267
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-09-07 16:27:18 +00:00
Paul Berry 6ca590a94e Migration: Replace ?. with . when target already migrated.
With this change, the migration tool no longer warns "Null-aware
access will be unnecessary in strong checking mode" for the specific
case where the target of a null-aware access is a non-nullable method
or getter invocation, and the method or getter in question is in
already-migrated code.  The whole point of the warning is to help the
user identify situations where the migration tool might have made the
wrong decision about code that it's currently migrating; that's not
useful if the method or getter was migrated previously.  So instead,
in these circumstances, the migration tool simply changes `?.` to `.`.

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

Bug: https://github.com/dart-lang/sdk/issues/49601
Change-Id: I8fe26df696dafa28ac1104f4b721f29bfe7ba164
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256646
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-09-06 20:23:36 +00:00
Konstantin Shcheglov d07005b4a2 Issue 49106. Update the context type for index in read/write.
Bug: https://github.com/dart-lang/sdk/issues/49106
Change-Id: I522269360c6664ac4a9129cb71bf378c9dfca812
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256647
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-09-01 16:24:52 +00:00
Konstantin Shcheglov ff8024fc78 Revert "Breaking changes for analyzer version 5.0.0"
This reverts commit d8df88cbe4.

Reason for revert: breaks Flutter HHH, requires updates to linter

Original change's description:
> Breaking changes for analyzer version 5.0.0
>
> Change-Id: Id9f27b6c41829249f6b2e7b93ad396643193fc78
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243164
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

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

Change-Id: I6ca213427189c169ddacbd89f60d463efa2c38f2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257122
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-08-31 21:05:19 +00:00
Konstantin Shcheglov d8df88cbe4 Breaking changes for analyzer version 5.0.0
Change-Id: Id9f27b6c41829249f6b2e7b93ad396643193fc78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243164
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-31 05:08:50 +00:00
Sam Rawlins 7dfe682557 Migration: _task is non-null
Change-Id: I5af61a0e8748d011b9c896ac23bc0bc82e08ae59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256240
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-08-24 20:29:40 +00:00
Paul Berry b1130abfb2 Migration: make warnOnWeakCode flag non-nullable.
The migration of the migration tool was done hastily (because it was
not expected to need much more maintenance) so it contains a lot of
nullable fields that don't need to be nullable.  I've been cleaning
them up as I run across them in order to unblock other work.  This is
one such cleanup.

Bug: https://github.com/dart-lang/sdk/issues/49601
Change-Id: I68413e23f565bc9d38af3345d28059d734a3c689
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256021
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-08-23 00:55:50 +00:00
Paul Berry 162091bd92 Migration: consider null-aware access an indication of nullability for parameters on public methods.
If a parameter of a public method is accessed using null-aware access
(`?.`), the migration tool now considers that to be an indication that
the parameter should be nullable.

Rationale: when migration doesn't have access to the entire code base,
the migration tool's approach of propagating nullability forward
through the program doesn't always work, because it's possible that
the sources of nulls are not visible to the migration tool.  This has
often resulted in the migration tool marking a function parameter as
non-nullable, in spite of the fact that the use of `?.` in the method
body makes it clear that it's intended to be nullable.

This new heuristic is only applied to public methods; for private
methods there's no chance of there being callers outside of the code
that's immediately visible to the migration tool, so the problem
doesn't arise.  For local functions and closures, the situation is
less clear-cut, but of the examples I've looked through so far in
Google's internal code base, it seems like more often than not, the
better behavior is to continue erring on the side of non-nullability.

Bug: https://github.com/dart-lang/sdk/issues/49601
Change-Id: I76531591ce0b3eb9fe62273130aa45eb4ff6d456
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253864
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-08-19 21:40:45 +00:00
Paul Berry 1f3ff13d98 Reland "Migration: fix generate_resources.dart to use dart compile js."
This is a reland of commit 6abea1381b

Original change's description:
> Migration: fix generate_resources.dart to use `dart compile js`.
>
> This is necessary because the command `dart2js` is no longer present
> in the SDK.
>
> Change-Id: Iea3cf3092bcda6c889c55a51d1b5601773404fb9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253862
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

Change-Id: Ibc25641aca165b578b2c4348ef0b841263298e3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-18 20:21:17 +00:00
Paul Berry 37ef55db8a Migration: add failing test to repro issue #49689
Bug: https://github.com/dart-lang/sdk/issues/49689
Change-Id: I00aaca8160b2bcd3de02eeb31ecc3efd6ec4a84c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255545
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-18 13:51:34 +00:00
Paul Berry 53ed7a156a Migration: fix types of DecoratedType.{positional,named}Parameters
These fields can be `null`, but if they aren't, then the
`DecoratedType`s they contain cannot be `null`.

Change-Id: I9f07d06017ff9814e531f3517b4f452766dc0ebf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255341
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-17 17:32:04 +00:00
Paul Berry 05eb57b0d1 Migration: add assemble_resources.dart script.
This script does the same job as `generate_resources.dart`, but it
doesn't search the filesystem for the input files to use, nor invoke
the compiler to create the `migration.js` file.  Instead, it simply
accepts a list of input files on the command line, and outputs their
contents in an appropriate form to be stored in `resources.g.dart`.

This script will allow us to integrate more cleanly with the internal
build system.

Change-Id: I4b5445d1f5fd7eccbb5fb36f6ee4fa97d2cea87e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254421
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-15 16:40:46 +00:00
Konstantin Shcheglov 82e33cc598 Add DartType.element2
Unfortunately my idea about checking for specific `DartType` subtype,
and only then asking for the element is too punitive. It almost
works in google3, but the amount and the kind of changes I had to
do make me realize that we should keep `get elementX` in `DartType`.

I guess this is the same as we had in AST when `get constructors`
does not make sense for mixins (?), but works for classes and enums,
and it is easier to pull it into the superclass.

Change-Id: Ibc4fac0b95d63748fa65de96d29300f477fdfc76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254482
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-08-11 16:01:48 +00:00
Paul Berry ac08c03dc6 Flow analysis: break up libraries.
This change breaks flow_analysis.dart into the following libraries:

- assigned_variables.dart (for the AssignedVariables class and related
  code)

- promotion_key_store.dart (for the PromotionKeyStore class)

- type_operations.dart (for the TypeOperations mixin and related code)

- flow_analysis.dart (for the rest of flow analysis)

And it breaks mini_ast.dart into the following libraries:

- flow_analysis_mini_ast.dart (functionality specifically concerned
  with testing flow analysis)

- mini_ast.dart (functionality not specifically related to flow
  analysis)

This is in preparation for trying to share some more type inference
behaviors between the analyzer and CFE.

Note that although the diff is big, the only changes in this CL are
moving code from one place to another, renaming some class members
from private to public, and updating imports.

Change-Id: I71768f03b1e75ed754c7b7af39f6cf7f03c4fe44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254462
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-11 13:18:52 +00:00
Konstantin Shcheglov 67f33caa5f Updates to prepare for analyzer 'name' breaking changes.
Change-Id: I0ef4226d30f923996a29af0d8f22c59c0e52f3a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254464
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-08-10 20:17:31 +00:00
Sam Rawlins 104d43fa59 Null-check after await.
This involves changing the target expression which must be null-checked
or awaited. When we detect the FutureOr and the await expression, we
instead null-check the await expression.

Fixes #44041

Change-Id: I08cf03f6975e2e70d5c87ebda92e9538de19e02e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253863
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2022-08-10 16:09:59 +00:00
Konstantin Shcheglov f4c009dc33 Deprecate Declaration.declaredElement, use 'declaredElement2' instead.
This is necessary to separate `ClassElement`, `EnumElement`, and `MixinElement`. And, in the future, augmentations like `ClassAugmentationElement`, etc.

Change-Id: Iecd2f8707212e53ef56f0e101880c7bab9e5d057
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254104
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-09 17:26:06 +00:00
Konstantin Shcheglov 75b8b916d6 Deprecate ClassOrMixinDeclaration, use ClassDeclaration or MixinDeclaration.
Change-Id: I23e292e9f7c4413edf9b068f057dd02794db21a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254064
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-08-08 21:40:40 +00:00
Paul Berry 09d13f194d Migration: make EdgeBuilder.variables non-nullable.
This is safe because this field is always initialized to a non-null
value before the EdgeBuilder is invoked.

Also, make `MigrationVisitorTestBase.variables` non-nullable; this is
safe for similar reasons.

Change-Id: I3a79efa8fb602dfe417a1e53937ddac4e129c86f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-08 12:36:20 +00:00
Paul Berry 4b61ceb1d2 Revert "Migration: fix generate_resources.dart to use dart compile js."
This reverts commit 6abea1381b.

Reason for revert: Breaks internal build of migration tool

Original change's description:
> Migration: fix generate_resources.dart to use `dart compile js`.
>
> This is necessary because the command `dart2js` is no longer present
> in the SDK.
>
> Change-Id: Iea3cf3092bcda6c889c55a51d1b5601773404fb9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253862
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,srawlins@google.com

Change-Id: I73c3321e6c473f5690eaddd94d13003c978234b6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253900
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-07 12:31:19 +00:00
Paul Berry fab3bc0467 Migration: enable the use of super parameters
Change-Id: Ie041191028bd0cd6c22571d1548a591f1852f89e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253861
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-08-07 12:28:39 +00:00
Paul Berry 6abea1381b Migration: fix generate_resources.dart to use dart compile js.
This is necessary because the command `dart2js` is no longer present
in the SDK.

Change-Id: Iea3cf3092bcda6c889c55a51d1b5601773404fb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253862
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-06 22:29:28 +00:00
Sam Rawlins f2f4b6df49 MigrationResolutionHooks._fixBuilder is not nullable
Change-Id: I23e6c51002624028f6c1f075b20ca831895279f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253741
Reviewed-by: Paul Berry <paulberry@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-08-05 13:04:57 +00:00
Konstantin Shcheglov cbfad8f802 Deprecate DartType.element, use specific element accessor for InterfaceType, TypeParameterType.
For `InterfaceType` keep `element2` deprecated and define
`InterfaceElement get element2` instead. Most changes are because
of this.

Change-Id: I13b888610fc707438c3c97b676f1460e7fc2b040
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253564
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-08-04 16:18:06 +00:00
Konstantin Shcheglov 528836c4aa Deprecate 'get enums/mixin', use 'get enums2/mixins2'.
Change-Id: I5c7dbb6dcc58537657e429893797b2631733ce16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252871
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-08-02 21:05:54 +00:00
Konstantin Shcheglov 71ef76ddfd Deprecate Element.enclosingElement2, use 'enclosingElement3'.
Change-Id: I0aba589bd42648eb420051cbe04bb3ef435081e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253400
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-02 18:00:14 +00:00
Konstantin Shcheglov 01173e2aa2 Deprecate 'name' in AST, use 'name2' token instead.
Change-Id: I867f009dca12208f835199297d2ea85c203c8556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252566
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-08-02 16:25:34 +00:00
Konstantin Shcheglov 33b672f789 Use CatchClauseParameter instead of SimpleIdentifier.
Change-Id: Ib254d05954548d4101fef9c2545d18b2611b59dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253100
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-01 17:32:04 +00:00
Konstantin Shcheglov 5f96a8c7fb Deprecate disjoined 'uriX' properties in favor of 'DirectiveUri'.
Change-Id: I6414f7e0f041a7a4454564195b2582e643f01b7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253024
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-07-30 19:39:42 +00:00
Anis Alibegić 40e18905f2 Fixed various typos in a lot of files
Closes https://github.com/dart-lang/sdk/pull/49478

TEST=Manual

GitOrigin-RevId: f4c9c6869dfe73639295e86574a021523b3d374d
Change-Id: I134a97caed4eec59d70e9cbca16b7e9a472cf2c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251902
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Chisholm <kevinjchisholm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2022-07-25 12:21:59 +00:00
Konstantin Shcheglov 2f3269faa1 Deprecate 'Element.enclosingElement', switch to enclosingElement2.
We need this for:
1. CompilationUnitElement changes its enclosing element from LibraryElement to LibraryOrAugmentationElement
2. Similarly PrefixElement.

Change-Id: I5e3719b4ef59d03caab1b20c9172a8c0fd786bdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251900
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-07-19 15:44:14 +00:00
Konstantin Shcheglov e23101a16f Rename to LibraryImportElement, LibraryExportElement.
Change-Id: I0928ca5522d9c67142111a8f3a7eb4d84f114f56
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/251844
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-07-18 20:01:18 +00:00