Commit Graph

38396 Commits

Author SHA1 Message Date
Johnni Winther e16a4e76e6 [cfe] Use flatten(T) as future value type for pre-nnbd async functions
Change-Id: I38d537112e66c08bb06bc2493b3126b5f8f797b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239022
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:42:22 +00:00
Johnni Winther a6acb1a5f0 [cfe] Include the future value type in ast-to-text
This is in preparation for including a "futureValueType" for
non-nnbd async functions.

TEST=existing

Change-Id: I15cf5e58623df07fe3c670aa866b7b04805c0f3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238703
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-28 10:37:25 +00:00
Daco Harkes 90f118484f [vm/ffi] Add Char C type
The diff from
https://dart-review.googlesource.com/c/sdk/+/229156/1..3

This was blocked by https://github.com/timsneath/win32/issues/349
earlier. Now that that has been resolved, we should be able to land
this.

We should land this to make package:ffigen be able to bind to `char` in
Dart 2.17.
https://github.com/dart-lang/ffigen/pull/287#discussion_r835734993

TEST=tests/ffi/c_types_test.dart

Change-Id: Ia3bc3785a3d5c0c9f7475106eb77f944f2d0a838
Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-ia32-try,vm-kernel-nnbd-mac-debug-arm64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-precomp-ffi-qemu-linux-release-riscv64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239020
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-03-28 09:46:56 +00:00
Jens Johansen bf6a181572 [CFE] Make macros work when initializing from dill
Previously, when initializing from dill, if the dill we initialize from
has a macro in it (and we don't remove it because of invalidation) the
macro system would think it was a precompiled dill and thus not compile
it as something it could use for running macros. Then when it tried
to use it, it would figure out it didn't have it (and crash).

This CL fixes the issue by reworking the logic:
* Assume the platform is there (dart: uris)
* Assume the uris given specifically as precompiled (and not removed
  because of invalidation in/by the incremental compiler) is there.

No tests are added, but it has been manually tested in flutter.

Change-Id: Ica6c4f2f0601334d50beccdd7cf9d5740e611384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239026
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-28 08:59:12 +00:00
Chloe Stefantsova ab62c34398 [cfe] Account for overall nullability of FutureOrType in UP
Closes https://github.com/dart-lang/sdk/issues/48631

Change-Id: I944da3a7f086a3d080de4f51bd99aa002f88cae6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239024
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-28 07:43:48 +00:00
Samuel Rawlins 5050f31b29 Revert "analyzer: Mark implicit-casts and implicit-dynamic as deprecated"
This reverts commit 6a54fdd46e.

Reason for revert: broke flutter-analyze

Original change's description:
> analyzer: Mark implicit-casts and implicit-dynamic as deprecated
>
> Also add a fix which replaces 'implicit-casts' with 'strict-casts' and
> a fix which replaces 'implicit-dynamic' with 'strict-raw-types'.
>
> Fixes https://github.com/dart-lang/sdk/issues/47902
>
> Change-Id: I293c3c1fd671ac85c12f9c050465b4d77632f241
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224800
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>
> Commit-Queue: Samuel Rawlins <srawlins@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ib2e9492716d3ff6da4fa4e1c64fd658451b16d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239008
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-27 16:56:01 +00:00
Brian Wilkerson 448bf930cc Remove an unneeded ignore comment in vm package
Change-Id: I3b81e1d66c2100b8ed1834815f318cf39a8da305
Tested: This only impacts the analyzer's reporting of diagnostics, so I ran the analyzer over the code and verified that no new diagnostics were being reported.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238983
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-26 16:10:31 +00:00
Daco Harkes 532c116cd2 [vm] Implement NativeFinalizer
This CL implements `NativeFinalizer` in the GC.

`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.

On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.

In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.

When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.

In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.

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

TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
Brian Wilkerson e5f118d194 Remove an unneeded ignore comment in dev_compiler
Change-Id: I90d4ee37e1599ad6981b379ca35c282efef923eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238982
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-03-26 00:08:27 +00:00
Brian Wilkerson 3b9906d048 Remove unneeded ignore comments in analyzer
Change-Id: I4e9ccbc2f45d8b547d63b607da11c1b96366f84a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238981
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-26 00:06:50 +00:00
Stephen Adams 567925e089 [dart2js] Sort URIs for JSON output
Ordering makes it easier to see the differences when regenerating with
`-g`.

Change-Id: I855e29bbbee3c01d7cc2f5c5787c52d9208af707
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239003
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-25 23:59:50 +00:00
Brian Wilkerson 77237a071c Remove unneeded ignore comments in vm_service
Change-Id: I42691dba8ba81603937e04b2d75b495874fedd7b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239001
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-25 23:12:14 +00:00
Paul Berry 83bea5cfbb Do an extra round of type inference before resolving deferred closures.
The order of operations for type inference of a generic invocation is
now:

1. Create some constraints on type parameters by trying to match the
   return type of the invocation target as a subtype of the incoming
   type context.  (For a constructor invocation, the return type of
   the invocation target is considered the raw uninstantiated type of
   the class enclosing the constructor declaration.)

2. Downwards inference: partially solve the set of type constraints
   accumulated in step 1, to produce a preliminary mapping of type
   parameters to type schemas.

3. Recursively infer all arguments to the invocation, except that if
   experimental feature `inference-update-1` is enabled, skip any
   arguments that are function literals (a.k.a. "closures").  Obtain
   the type contexts for the recursive inference by substituting the
   preliminary mapping (from step 2) into the corresponding parameter
   types of the invocation target.  For each argument that is
   recursively inferred, create additional constraints on type
   parameters using the resulting static type.

4. If no arguments were skipped during step 3, go to step 7 (this
   always happens if `inference-update-1` is disabled).

5. Horizontal inference: partially solve the set of type constraints
   accumulated so far, to produce an updated preliminary mapping of
   type parameters to type schemas.

6. Recursively infer all of the invocation arguments that were
   previously skipped.  As in step 3, obtain the type contexts for the
   recursive inference by substituting the preliminary mapping (this
   time from step 5) into the corresponding parameter types of the
   invocation target.  Again, for each argument that is recursively
   inferred, create additional constraints on type parameters using
   the resulting static type.

7. Upwards inference: solve the set of type constraints accumulated so
   far, to produce a final mapping of type parameters to types.  Check
   that each type is a subtype of the bound of its corresponding type
   parameter.

8. Check that the static type of each argument is assignable to the
   type obtained by substituting the final mapping (from step 7) into
   the corresponding parameter type of the invocation target.

9. Finally, obtain the static type of the invocation by substituting
   the final mapping (from step 7) into the return type of the
   invocation target.

This addresses simpler cases of
https://github.com/dart-lang/language/issues/731.  Note that if
experimental flag `inference-update-1` is disabled, the behavior is
unchanged.

Note that steps 2 and 5 use the same algorithm as each other (they
only differ in how many type constraints have been accumulated so
far), so I've renamed the function that performs it from
`downwardsInfer` to `partialInfer`.

Change-Id: I10d3288d4f4ba9e2b6bc18409186ddc67ca2ee9d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238881
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-25 22:07:50 +00:00
Stephen Adams 2a1dba465c [js_ast] Migrate nodes.dart and printer.dart
Change-Id: I671749e6775d3df6e7781709429c772da4c412bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238760
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-25 21:14:40 +00:00
Ben Konyi 0950d887be [ package:dds ] Fix devtools_server_test flakiness
The test harness wasn't waiting on `CliAppFixture.onAppStarted` which
could cause an unhandled exception if the test cleanup started before
the target application finished initializing. This typically only
occurred while the test was running on a machine under load.

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

TEST=Locally while running under load (e.g., `stress -c 72`)

Change-Id: Ieb67e46f62c33101490899440574fb57fc0f8882
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238922
Reviewed-by: Kenzie Davisson <kenzieschmoll@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-03-25 18:40:30 +00:00
Brian Wilkerson 5a542ce2b1 Enable links to newly published documentation
Change-Id: Iace45474f783b833d7095d55259a9e285bf554b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238460
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-25 18:18:00 +00:00
Ahmed Ashour f1ab934eaf Add fix for cascade_invocations lint.
Fixes #47957

Change-Id: Ic6bcbe86c7c9bf4434cef7eec0f2f4a44897f5c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238581
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-25 17:59:33 +00:00
Mark Zhou 1e706215d1 [dart2js] Adding experimental flag for emitting treeshaking info
This will eventually be merged with --dump-info

Change-Id: I81884868521abc542bb0268912bfb37e6241cac5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238500
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-25 17:21:40 +00:00
Ahmed Ashour 59b7b8c818 create_constructor_super to use super initializers
Fixes #47979

Change-Id: Ic6131d43b74a5a48ad901e56c0de474a03e2d552
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-25 16:58:51 +00:00
Paul Berry 5c0e0922d0 Defer analysis of closure arguments when inference-update-1 is enabled.
In order to address https://github.com/dart-lang/language/issues/731
(improved type inference for `fold` etc.) we're going to need to
sometimes defer analysis of invocation arguments that are closures, so
that closure parameters can have their types inferred based on other
parameters.  To avoid annoying the user with inconsistent behaviors,
we defer analysis of closures in all circumstances, even if it's not
necessary to do so for type inference purposes.

This has a minor user-visible effect: if an invocation contains some
closures and some non-closures, any demotions that happen due to write
captures in the closures are postponed until the end of the
invocation; this means that the write-captured variables remain
promoted for other invocation arguments, even if those arguments
appear after the closure.  This is safe because there is no way for
the closure to be called until after all of the other invocation
arguments are evaluated.  See the language tests in this CL for
details.

Note that this change only has an effect when the experimental feature
`inference-update-1` is enabled.

Change-Id: I283fc5eb07af2aeca0a06d523011d8c4617fbad7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237720
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-25 16:40:10 +00:00
Joshua Litt 9f33a4a052 [dart2js] Inline CompilerDiagnosticReporter into its super.
Change-Id: I3b675df3069f2ff7cb74374bcc2ee1caa31e8610
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238800
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-25 16:15:50 +00:00
Mark Zhou ca99bde913 [dart2js] Cleaning up codegen inputs and dart2js_info
Change-Id: I844b43580dbf8738b72e638b24be726e878f8635
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238780
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2022-03-25 15:22:20 +00:00
Sam Rawlins 6a54fdd46e analyzer: Mark implicit-casts and implicit-dynamic as deprecated
Also add a fix which replaces 'implicit-casts' with 'strict-casts' and
a fix which replaces 'implicit-dynamic' with 'strict-raw-types'.

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

Change-Id: I293c3c1fd671ac85c12f9c050465b4d77632f241
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224800
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-25 14:58:50 +00:00
Chloe Stefantsova 6b7c23150f [cfe] Adjust const context in constructors with super parameters
Closes https://github.com/dart-lang/sdk/issues/48642

Change-Id: Id9f29ca248c69175ec05d6371baaa8f0aab8dc0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-25 11:11:20 +00:00
Brian Wilkerson 61954676ea Add code style options for code generation
Change-Id: Ibc5087aeb88965488502cca74923df6d7a2b185e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238761
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-25 04:47:31 +00:00
Konstantin Shcheglov 143fe67673 Make fields in CompilationUnitElementImpl final and/or non-nullable.
Change-Id: I604ad776196fa90bccf2ba06fa282fa0e7979d18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-03-25 01:20:19 +00:00
Nicholas Shahan a34c8a6776 [ddc] Break SwitchCase into Case and Default nodes
- Removes another diff between this version and the package:js_ast.
- This is helpful for the null safety migration as the expression
  in the Case node can now be non-nullable.

Change-Id: Ia6626b2ee8a4e8b66bc6b53ea74d16d2d9f81f7a
Issue: https://github.com/dart-lang/sdk/issues/46617
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238663
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-03-24 22:09:09 +00:00
Paul Berry b07c7798ca Push logic for constraining argument types into InvocationInferrer._visitArguments.
This allows us to avoid some redundant computation (we don't have to
match up arguments to the corresponding parameters twice).  It also
paves the way for supporting improved type inference of `fold`
(https://github.com/dart-lang/language/issues/731) because it will
allow us to resolve some arguments (gathering more constraints), then
compute a new set of inferred types, then resolve more arguments, and
so on, rather than forcing us to do all the constraint gathering at
the end.

Change-Id: I67d8b8228390ced14281145a4614f66c8e3c7e73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238622
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-24 20:51:21 +00:00
Ryan Macnak 464bece529 [vm, compiler] Fix some stack alignment for RISC-V FFI.
- Fix bad frame walk from assuming kSavedCallerFpSlotFromFp is 0.
 - Fix sign of WChar.
 - Fix missing sign-extension in some cases of passing uint32.

TEST=qemu
Bug: https://github.com/dart-lang/sdk/issues/48164
Change-Id: Idc1699d473a115153b4b4e6fdc9f84519055de00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238386
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-03-24 20:45:09 +00:00
Brian Wilkerson 7be81a875a Move AnalysisOptions out of src
In the process, I removed 'useFastaParser' from both the public API and
the implementation class. I also removed 'enableTiming' from the public
API.

The other getters were left because they seem like reasonable options
for plugins to want to query. If you disagree, we can address them in a
future CL.

Change-Id: Ia5630b71190dd68bcd66199baa0c05846fcc37b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238661
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-24 20:43:19 +00:00
Konstantin Shcheglov 0952bcc9c3 Set placeholder LineInfo when to informative data.
Bug: https://buganizer.corp.google.com/issues/226516358
Change-Id: I3e99819d78b3904602b61fa9e498ae14e8e04a5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238623
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-03-24 20:11:12 +00:00
Ahmed Ashour 539e14296d FINAL_NOT_INITIALIZED_CONSTRUCTOR not to be reported for static fields.
Fixes #48180

Change-Id: I3c296fb6e307b5dd6cf0dd53cbc7297a88146e81
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238358
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-03-24 19:12:21 +00:00
Nate Biggs 49c1a91587 [dart2js] Refactor serialization/deserialization implementations (6/6)
Rename DataSource -> DataSourceReader and SourceReader -> DataSource to more accurately reflect these classes' new roles. 'Writer' and 'Reader' are used for the higher level class that composes serialization operations. The 'Sink' and 'Source' handle the low-level conversions to/from the storage format.

Change-Id: I384b5f134beb040676f8e1ef4fba056e0c40358f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238243
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs f0b1143bc6 [dart2js] Refactor serialization/deserialization implementations (5/6)
Copy comments from original interfaces to new DataSink and DataSource and organize methods based on original interface.

Note: If the reorganization makes the diff on this too complicated I can just add the comments and leave in the order it was in.

Change-Id: I959ae19d80ad330ef67334effb8aad8661689937
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238242
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs c4c013b7f7 [dart2js] Refactor serialization/deserialization implementations (4/6)
Move DataSource/DataSink to implement serialization via composition rather than inheritance taking simple interfaces that do low-level writes/reads.

Note: Names and locations of classes will change throughout the next several CLs.

Change-Id: I04807d64a1238b42308ec93e5b5dda6ef2101c00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238241
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs 4f4b4d06b5 [dart2js] Refactor serialization/deserialization implementations (3/6)
Combine AbstractData(Source/Sink) and Data(Source/Sink) into a single class. This simplifies the inheritance hierarchy before switching to a composition structure.

Note: Names of classes will change throughout the next several CLs and comments from the interface get added back in here:
https://dart-review.googlesource.com/c/sdk/+/238242

Change-Id: I50597e04f5b18a1150da4822c4886d12896bed8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238240
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Nate Biggs 20ca69b8b7 [dart2js] Refactor serialization/deserialization implementations (2/6)
Copy mixin logic into AbstractSink/AbstractSource classes since these are the only usages of the mixins.

Note: Names and locations of classes will change throughout the next several CLs.

Change-Id: Ie154741a83c3488a098f3ebf5cf340f19a1a9c52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238220
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 18:50:19 +00:00
Stephen Adams 2e984a382d [js_ast, dev_compiler/js_ast] Use libraries instead of parts
This will allow more gradual migration of js_ast.

Change-Id: I3e948ad5c79fa9880b7eb3bccd7c15cbf9786e32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238660
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-24 18:38:14 +00:00
Nate Biggs 59c4fc3260 [dart2js] Refactor serialization/deserialization implementations (1/6)
Rename abstract class files in preparation for refactor.

Note: Names and locations of classes will change throughout the next several CLs.

Change-Id: Ibf1e56b9e1e550fd14f6b2b803b6bbbc2d7cae3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238162
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-03-24 18:34:49 +00:00
Stephen Adams 8fb1d7084b [js_ast, dev_compiler/js_ast] Pre-migration cleanup 1
This won't promote for a nullable field `foo`, so use `?.`:

    if (foo != null) foo.accept(this);
-->
    foo?.accept(this);

Change-Id: I0f3c92803f8756c44a959d17dfe29b12f9db362c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238501
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-03-24 18:28:30 +00:00
Konstantin Shcheglov ebcf8a37e4 Wait for applyPendingFileChanges() when resolveForCompletion().
Change-Id: I1d2d07f613cfa0221a15e3d7b9873cc3d8564ece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238502
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-03-24 17:51:01 +00:00
Konstantin Shcheglov cbcbf898cf Prepare to publish analyzer 3.4.1 and _fe_analyzer_shared 38.0.0
Bug: https://github.com/dart-lang/sdk/issues/48658
Change-Id: I1d3d531cf3550a657a1cdd9d7a29467e4c92df0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-03-24 17:44:29 +00:00
Mark Zhou f3bea1a550 Fixing internal README markup issue
Google3's markup prefers newlines before triple-backticks

Change-Id: I6704fed06eb54a75048a82130f5cdaa469d90e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238621
Commit-Queue: Mark Zhou <markzipan@google.com>
Auto-Submit: Mark Zhou <markzipan@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-03-24 17:36:00 +00:00
Chloe Stefantsova d291c5330f [cfe] Report errors in inherited restricted members in enums
Part of https://github.com/dart-lang/sdk/issues/47453

Change-Id: I5f80c3507a0264c4516d42967b148f4dc3fd08ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237684
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-24 17:17:39 +00:00
Nicholas Shahan ac2c6502ed [web] Update format of comments
Reduce the number of diffs between pkg/js_ast and
pkg/dev_compiler/lib/src/js_ast

Change-Id: Ic00e1614b23e11118383e954a0ee31365d65ebe6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238388
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2022-03-24 16:51:29 +00:00
Nicholas Shahan fdf5a4130c [ddc] Prepare nodes.dart for null safety migration
Preliminary changes to better isolate the nullability.

Change-Id: I3fed4ccbcb62185c84ff53e1463426322cdc1fbd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238387
Reviewed-by: Stephen Adams <sra@google.com>
2022-03-24 16:51:29 +00:00
Chloe Stefantsova 050ffd6d70 [cfe] Report errors on restricted members in Enum implementers
Closes https://github.com/dart-lang/sdk/issues/48577

Part of https://github.com/dart-lang/sdk/issues/47453

Change-Id: I949052f153c2e7b1c818069149c75b977ca8ac95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237580
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-03-24 16:29:59 +00:00
Paul Berry f3494f07e5 Remove unnecessary call to _recordIdenticalInfo.
We don't need to call this method from
`InvocationInferrer.resolveInvocation`, because resolution of a call
to `identical` always uses the derived class
`MethodInvocationInferrer`, which inherits proper handling of
`identicalInfo` from `FullInvocationInferrer.FullInvocationInferrer`.

Change-Id: Ic511befee498bd241d2d33240b4b388a0ed74be4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-24 16:06:32 +00:00
Paul Berry 3897cd0157 Push substitution logic down into _visitArguments.
Rather than compute a preliminary `invokeType` prior to calling
`_visitArguments`, we just compute the necessary substitution to go
from `rawType` to `invokeType`, and let `_visitArguments` apply it
when needed.  This will improve efficiency when I add support for
better type inference of `fold` (see
https://github.com/dart-lang/language/issues/731), because it will
allow multiple passes of type inference without having to recompute
`invokeType` each time.  Also, it gives `_visitArguments` access to
the `rawType`, which I will take advantage of in a follow-up CL to
make constraint generation happen at a more reasonable time.

Change-Id: I2ecabac10c0ec91fc994b4cf2d8f33a5b532a99e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238600
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-24 16:02:13 +00:00
Paul Berry 2dbafcc40c Split InvocationInferrer.resolveInvocation into two methods.
`_visitArguments` handles walking through the argument list,
recursively performing type inference on each argument.
`_recordIdenticalInfo` handles the necessary integration with flow
analysis to support type promotion via `identical(variable, null)`
tests.

We no longer call `super.resolveInvocation` from the overriden method
`FullInvocationInferrer.resolveInvocation`, but instead call
`_visitArguments` and `recordIdenticalInfo` directly.

This is part of a larger arc of work to enable better type inference
of `fold` and similar methods (see
https://github.com/dart-lang/language/issues/731).  It will allow me
to add some additional parameters to `_visitArguments` that relate to
type inference, without complicating the API of `resolveInvocation`.

Change-Id: I6d8ac1af4cfbadf86d5fbfd4ba1b4652707ecfdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/238505
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-03-24 15:57:32 +00:00