Commit Graph

52459 Commits

Author SHA1 Message Date
Paul Berry fb2ada0ee0 [flow analysis] Simplify reachability computation in attachFinally.
Previously, `attachFinally` took advantage of
`Reachability.rebaseForward` to compute reachability after a
`try/finally` statement. This was overkill, since
`Reachability.rebaseForward` contains special logic to account for
widely diverging reachability stacks, whereas `attachFinally` always
deals with reachability stacks that have an immediate common parent.

This change adds an assertion to verify that the reachability stacks
always have an immediate common ancestor, and replaces the call to
`Reachability.rebaseForward` with the equivalent direct logic.

Making this change will simplify the process of writing a spec for
flow analysis.

Change-Id: Icd7d3ebc150d1836932efe3891b3ea1077134351
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437300
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-27 05:20:23 -07:00
Johnni Winther 0dbc8c0107 [cfe] Split type_parameter_scope_builder.dart into multiple libraries
Change-Id: I90a200feb4bf829825d55720665d082f7e852ad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437420
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-27 04:05:27 -07:00
Johnni Winther b8638d9e2e [cfe] Add SyntheticDeclaration
This adds a SyntheticDeclaration interface and uses it to add enum values.

Change-Id: I91b5a255032a5071dfc286358970d5d50108223b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437223
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-06-27 03:23:11 -07:00
Johnni Winther bb9252a605 [cfe] Report conflicts through _Declaration
The reports the declaration conflicts through the _Declaration objects,
which streamlines the code and helps providing more targeted messages.

Change-Id: I013c9974de87c5a1c541ba6aa5d78a1ba63e1074
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437241
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-27 03:23:11 -07:00
Jens Johansen e656fec1ee [CFE/Analyzer/parser] Fix crash upon double with separators and missing number after e
E.g. the user typing "1_234e" (and having yet to type a number) would
crash the analyzer.

Change-Id: Iff71c274a5e4719b3c8877ddbc9775d8d091c42f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2025-06-27 02:29:33 -07:00
Konstantin Shcheglov d79ebc6165 Elements. Remove ExecutableElementOrMember.
Change-Id: I1a48c337a3b74058bd9c62cf8b95e3eabfd8f4b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437263
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-27 00:50:19 -07:00
Jens Johansen 90fb141aa2 [analyzer] Speedup assist calls when file has non-Windows line-endings
Before an assist call on a file with non-windows lineendings would first
search through the entire file for Windows line endings, then search for
the non-Windows line endings. As such Windows line endings was faster.

This CL changes the semantics slightly from "Windows line endings if
any Windows line endings exist" to "whatever line endings are first
used" which should be good.

It speeds up assist calls with non-Windows line endings:

Statistics on 5 runs each:

```
Windows / 2000: No change.
Windows / 4000: No change.
Windows / 8000: No change.

Unix / 2000: 1000 assist calls: -46.9900% +/- 6.1715% (-0.88 +/- 0.12) (1.86 -> 0.99)
Unix / 4000: 1000 assist calls: -59.1561% +/- 6.3982% (-1.79 +/- 0.19) (3.03 -> 1.24)
Unix / 8000: 1000 assist calls: -63.8429% +/- 4.3083% (-3.68 +/- 0.25)(5.76 -> 2.08)
```

Change-Id: I61278ed4ad31b891e87951da0a6162fe37376888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437224
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-26 23:26:20 -07:00
Konstantin Shcheglov 28d25e437e Elements. Remove 'variable' and 'toFunctionValue' from DartObjectImpl.
Change-Id: Ia696347266cb4b54f5248fb1f9f0f73290fddc5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437380
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 17:23:01 -07:00
Konstantin Shcheglov 0e12390e63 Elements. Remove PropertyAccessorElementOrMember.
Change-Id: I3882b02140021fbb2733ff8f5ff2ae575ab129fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437361
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-26 17:16:13 -07:00
Konstantin Shcheglov 7505e450f5 Elements. Remove 'get identifier' from ElementImpl and FragmentImpl.
We used it to construct `ElementLocation`, and we already removed it.

Change-Id: Ie88ba3aae24f094c6eb2c5b656cc64398e5ba91b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437360
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 16:47:12 -07:00
Fedor Shcheglov c8f8ba6875 Deprecate Element.accept2, use accept instead.
Change-Id: I4ec0389663164b8dde0b0321e4457f2ae655785a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435745
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-26 15:02:22 -07:00
Brian Wilkerson b402fac6fa Adds library cycle data to the analytics.
The two pieces of information we're tracking are
- the number of libraries in each library cycle
- the number of lines of code in each library cycle

The data is reported in terms of percentage.

This doesn't give us any way to correlate the two values. Knowing that
there is a library cycle with M libraries and a cycle with N lines of
code, doesn't tell us whether it's the same library cycle in both cases.
Still, I think it will help us understand the nature of the code that
we need to be able to analyze quickly.

Change-Id: I36a8bf11c4c6fdced6c524225be7a633062351ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437126
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-26 14:54:52 -07:00
Parker Lougheed 873a88bd6d [analyzer/linter] Mark a few diagnostic docs as published
Also regenerate the diagnostic codes and (deprecated) lint rules.json file.

Change-Id: Id50dfe81a7bc3a62fee9d6b99f0e045804e95685
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436960
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-06-26 13:38:04 -07:00
Danny Tuppeny 5d2d5cb8ba [analysis_server] Pre-compile server for integration tests
By default the integration tests spawn the server using the snapshot from the active SDK. If you forget to recompile the SDK when running the integration tests, you may get inaccurate results.

One option is to set the `TEST_SERVER_SNAPSHOT` env variable to `"false"` which will run the tests from source, however using the "Run All Tests" command in VS Code will result in a lot of timeouts because tests run concurrently and each one will cause a compilation.

This change instead creates a new VS Code task that will compile the server to a temporary file in `.dart_tool`, and creates a launch configuration that triggers this task (via `preLaunchTask`) when running integration tests. This supports both running all tests (with the "Run All Tests" command) or running individual integration test files, with just a single up-front compilation.

Change-Id: I0970ffb76240abd54ff2c8a9c9be4bab40693691
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436341
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2025-06-26 13:35:13 -07:00
Jake Macdonald 5e562b2383 add basic tests for the dart mcp-server command
Change-Id: I7c6071fc7b015f8d7e0cbdf4b2cb2d31358d442c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437140
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2025-06-26 13:24:40 -07:00
Konstantin Shcheglov 4d36ef3a37 Elements. Remove MethodElementOrMember.
Change-Id: I062e1a55867ba541290ed948081cf4ea26dab2cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437320
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 12:47:53 -07:00
Konstantin Shcheglov 56536ba054 Elements. Remove ConstructorElementMixin.
Change-Id: I4a5391d4a886f6d69c7bec35c86bd6b4e82d9c03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437261
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-26 12:46:59 -07:00
Sam Rawlins a8414a4962 vm_service: Use less dynamic, both explicit and implicit
Change-Id: Idde221b094fd23ded8e6d77d47f8ce73ab2549c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437022
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-26 12:07:31 -07:00
Patt O'Brien c537260fab fix: Typos in element model migration guide.
Closes https://github.com/dart-lang/sdk/pull/60998

GitOrigin-RevId: bae0908f7b5a956b2ffd2f0fcd8fda64af60cc55
Change-Id: Iea1879bfc62016e0f70bc442a197aae321e17b61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437125
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2025-06-26 11:56:11 -07:00
Sam Rawlins 1091aed650 DAS: only attempt to compute fixes for fix-supporting producers
The diff makes this change look bigger than it is.

Here's how the code worked before: `compute()` called `_addFromProducers()`. `_addFromProducers()` had a local function, also
called `compute()`, which is called per CorrectionProducer. The local
`compute()` function would unconditionally create a ChangeBuilder and
call each CorrectionProducer's `compute()` method, then call back out
to an instance method called `_addFixFromBuilder()`, which would drop
the computed change on the floor if `fixKind` was `null`.

This CL contains the following changes to the above system:

* The local `compute()` function and the instance method,
  `_addFixFromBuilder()` are combined together, into one instance
  method, `_addFromProducer()`.
* Then, the `fixKind` check is moved to the very top of that
  method, bailing out _before_ computing changes if `fixKind == null`.

Change-Id: I6c61059fc36ec1587b15ca01b43830a5b179da9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417326
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-26 10:51:44 -07:00
Konstantin Shcheglov bdc01d108e Elements. Stop using ConstructorElementMixin in constants evaluation.
Change-Id: I54e22bd9a0068ffa8de5a7ded932131327f672fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437105
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-26 10:44:39 -07:00
Kallen Tu 78b27083c9 [analyzer] Dot shorthand: Update constant verification for default parameter values.
The constant visitor was missing an extra check that we had for instance creation expressions, but not for dot shorthand constructor invocations. It's definitely a little funky because of how we've chained up the ConstantVisitor + ConstantVerifier, but this is how we currently handle this error.

Added a unit test.

Fixes: https://github.com/dart-lang/sdk/issues/60962
Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I76489a425c5e01c4d9edb34ac6dc62f109e6a32a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436821
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-26 10:43:40 -07:00
Kallen Tu c7765a8205 [analyzer/linter] Dot shorthands: Update ConstantVerifier for dot shorthand constructor invocations.
Updates the `ConstantVerifier` so we're checking the dot shorthand constructor invocation is a constant constructor call and that its arguments are constant expressions.

Tweaked the constant error handling a little bit to handle dot shorthands. It's always a little funky, but needed to prevent duplicate errors.

Added a few unit tests from the example in the bug.

Fixes: https://github.com/dart-lang/sdk/issues/60963
Bug: https://github.com/dart-lang/sdk/issues/60893
Change-Id: I77b2dff4a274241b2c98b3e6cd34c620d08435a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436742
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-06-26 09:52:12 -07:00
Paul Berry 59db156aee [flow analysis] Make split/conseravativeJoin order more uniform.
While doing specification work for flow analysis, I noticed that in
circumstances where a flow model needs to have both the `split` and
`conservativeJoin` operations applied to it, sometimes flow analysis
applied `split` first, and sometimes it applied `conservativeJoin`
first.

The actual order doesn't matter, since `split` only affects the flow
model's reachability, and `conservativeJoin` only affects the flow
model's variable info. But for the purpose of making the specification
clearer, it's nice to be consistent. This change adjusts the order so
that `split` always happens before `conservativeJoin`.

Change-Id: Ia5dfc9335ee85f122ae274f6bb850f83f12b88d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-26 09:28:52 -07:00
Daco Harkes 592e5c144a [native assets] Support PATHEXT invocations with appended snapshot
This CL introduces an `IsolateData::asset_base_path` which contains
the fully resolved base path used for assets which are loaded with a
relative path. (Resolving both PATHEXT and symlinks.)

The asset base path is now only resolved once, instead of on every
relative asset load.

The asset base path is now eagerly resolved.
To prevent existing error messages for files not existing changing in
`dartdev` and `Isolate.spawnUri`, files not existing errors are
ignored.
To prevent `tests/standalone/io/named_pipe_script_test.dart` from
failing, failing to canonicalize a file path is treated as no asset
base path rather than reporting a failure.

TEST=pkg/dartdev/test/native_assets/*.dart

Bug: https://github.com/dart-lang/sdk/issues/60946
Change-Id: I79a9144d220dfb3e54311725d41f8f91c88db3a1
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-win-release-arm64-try,pkg-win-release-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-android-release-arm64c-try,vm-aot-linux-debug-x64-try,vm-aot-mac-debug-arm64-try,vm-aot-win-debug-arm64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-msan-linux-release-x64-try,vm-asan-linux-release-x64-try,vm-linux-release-x64-try,vm-linux-debug-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435421
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-06-26 07:47:32 -07:00
Fedor Shcheglov 86df26dd2f Consolidate fragment writing into _writeTemplateFragment.
Migrate hand-rolled _writeXxxFragment helpers to the shared _writeTemplateFragment. This eliminates duplicated serialization logic  (ID / name / offset / modifiers), shrinks the code base, and makes it easier to add new fragment types without boiler-plate.

Removed flags from `bundle_reader` and `bundle_writer`, will remove flag classes in the future as they will be replaced with reading/writing modifiers.

Change-Id: I79aabd1e94bfa831d6718bb2889a6a00e6561112
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-26 06:10:31 -07:00
Jens Johansen 1530dcc679 [analyzer] Return null faster in _getDocumentation on DocumentationPreference.none
For some requests this seems to be ~3.5-4.5% faster.

Change-Id: Ifff8656dc1237e1d0014305efa31906be9120d05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436903
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-26 01:38:49 -07:00
Jens Johansen 2910b812fc [analyzer] Fix wrong .run call in lsp completion handler; add timing to sendResponse
E.g. when sending 2000 results to a completion request, sending (json
and utf8 encoding) can be a very big part of the cost and it's very
confusing having it attributed to "self" in "request".
Also `mapSuggestions` looked much cheaper than it was because it used
`run` instead of `runAsync`.

Change-Id: Ifd219adb25fa658930548536eb8eb46276acd4a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436922
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-26 01:38:02 -07:00
Jens Johansen 863bc97881 [analyzer] Speedup receiving of data in benchmark
Change-Id: I3e37a1d8b17393ce3c41e33b1b90049c754cc595
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436921
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-26 01:07:09 -07:00
Ryan Macnak b374d4265b Revert "[test_runner] Use relative paths in commands."
This reverts commit 1b4a56692b.

Reason for revert: breaks Fuchsia builders

Original change's description:
> [test_runner] Use relative paths in commands.
>
> This makes it easier to copy commands between checkouts or between the bot and local development.
>
> Change-Id: I74bc9dcb83855e295fe40fa4ef81871ccc537d29
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400180
> Reviewed-by: Alexander Aprelev <aam@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I8c7cca1e9c82a5b6e237d0b7611647a6168e6397
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437123
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Ryan Macnak <rmacnak@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-25 18:08:07 -07:00
Fedor Shcheglov 98f233bfa7 Deprecate InterfaceType.constructors2, use constructors instead.
Change-Id: I2d63bc1b61acb781ad0b8a45f15a05d36ee3a304
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435748
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-25 17:38:01 -07:00
Nicholas Shahan 884a48c988 [ddc] Delete macro options and cli arguments
Change-Id: I83bd63f707758e82ac23a80b7442d57746f6b125
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436941
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-06-25 15:21:55 -07:00
Konstantin Shcheglov 9270f0fad0 Elements. Stop implementing ConstantEvaluationTarget by ElementAnnotation.
This is an internal interface that should not have been exposed.

Change-Id: I92ddc64766e3b9d183750a3406d03215275a58a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436741
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-25 15:20:10 -07:00
Ryan Macnak 1b4a56692b [test_runner] Use relative paths in commands.
This makes it easier to copy commands between checkouts or between the bot and local development.

Change-Id: I74bc9dcb83855e295fe40fa4ef81871ccc537d29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/400180
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-25 15:13:50 -07:00
Brian Wilkerson 8f1a2b39ea Bump tools to 7bf22c951019f860aa52a8b7dc97fba5880aa9ba
Changes:
```
> git log --format="%C(auto) %h %s" 1e110fc..7bf22c9
 https://dart.googlesource.com/tools.git/+/7bf22c95 [unified_analytics]Add library cycle info to analysis server data (2117)

```

Diff: https://dart.googlesource.com/tools.git/+/1e110fcf8da4fbd423e22ae7d14f04c908d7c139..7bf22c951019f860aa52a8b7dc97fba5880aa9ba/
Change-Id: I0cd6893dc35fd4dc938070afb4ec1c2f45054dea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436943
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2025-06-25 15:08:46 -07:00
Fedor Shcheglov b017489312 Removed ElementModelWriter due to it being unused.
Change-Id: Ib2bb8b877e23fdff884bd03b208ea4d077c6e927
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437120
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-25 15:04:34 -07:00
Konstantin Shcheglov 3e6edd36e1 Elements. Remove deprecated methods from InheritanceManager3.
With mockito migrated off of them, we can now remove them.

Change-Id: Ib5e3d354cdf2d9b44d0d3a87e4dfa024b8fdb29f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437040
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-06-25 15:00:43 -07:00
Fedor Shcheglov a801e69e26 Consolidate fragment reading into _readTemplateFragment
Replace eight bespoke implementations for reading fragments with the existing `_readTemplateFragment()` method.

This enforces the consistent use of the template method design pattern, reduces code duplication, and makes future maintenance easier.

Change-Id: If213b146e4b055523432c6d12f36994cac8f38c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436820
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-06-25 14:36:12 -07:00
Ryan Macnak bb08090c5a [test] Mark package:vm_service tests as Slow.
Change-Id: I51a7e29e25e409965e1bb581f8edd8ef39345a87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437020
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2025-06-25 13:39:50 -07:00
Sam Rawlins 04e11b83c0 DAS: Make CreateMethodOrFunction.fixKind final
With this change, CreateMethodOrFunction complies with the contract
that `fixKind` not change before/after `compute()` is called.

This change includes some tidying to simplify the code:

* The decision of whether to use `DartFixKind.CREATE_METHOD` or
  `DartFixKind.CREATE_FUNCTION` is solely based on whether the
  "target element" is an InterfaceElement. So in the new factory
  constructor, we compute the "target element", and save that in a
  final field, as well as the fixKind.
* `isStatic` was computed eagerly with other variables in a nest of
  else-if bodies. But it is only needed when creating a _method_, and
  so it's value can be computed nearer to where it is used.
* `compute()` was ~100 lines long, and a lot of that code was dedicated
  to computing the parameter type. Intermediate values like `argument`
  and `parameterElement` sort of clutter the local variables; all of
  that code can be moved to a function that just computes the
  parameter type.

Change-Id: Ibd5d96b752e7e03e52f585bb594c34331b08cdf1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-25 12:15:41 -07:00
Kallen Tu 2d6a8211eb [linter] Dot shorthands: Update no_logic_in_create_state lint.
Updated the lint to handle the dot shorthand constructor invocation case.

Added unit tests.

Fixes: https://github.com/dart-lang/sdk/issues/60976
Bug: https://github.com/dart-lang/sdk/issues/60893
Change-Id: I4ba65e28b17b4357af0e09ad2cc0139177062583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436800
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-25 10:24:19 -07:00
Sam Rawlins 64060a8ddf vm_service: Assign fields in field initializers
This is achieved with just a bit of delicacy around commas, braces,
semicolons, and possible super-initializers.

There is exactly one case of a statement that needs to remain in the
constructor body: `_parseTokenPosTable()`.

Additionally I add one helper, `_createServiceObjectListOrNull`, which takes care of some casting and nullability quirks. This also includes one small perf improvement: when `createServiceObject` returns null,
we immediately return an empty list, without wrapping it in `List.from`.


vm_service: helper for list fields
Change-Id: Ic5e36bbfa451bea06edf0d9e684705d392f1ad39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436540
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2025-06-25 08:57:13 -07:00
Daco Harkes 59ed4ebde9 [dartdev] Organize dart --help commands into categories (2)
TEST=pkg/dartdev/test/commands/help_test.dart

Change-Id: I4e6eed1093412c8b307713c0faf95a84d56b5f26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436905
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-06-25 08:39:04 -07:00
Ömer Ağacan 560b017773 [dart2wasm] Pass --enable-threads to wasm-opt
With --import-shared-memory we import a memory, which requires
--enable-threads flag to be passed to wasm-opt.

Change-Id: I25198344f8c918cec28b2b22262e2b9d70a137ea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436923
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2025-06-25 08:13:11 -07:00
Sam Rawlins ee69f45a1f analyzer: rework AnalysisErrorListener deprecation
Work towards #60635

In this change, we rework the AnalysisErrorListener deprecation to
better support users who have their own class that implements
AnalysisErrorListener. This change introduces a sealed supertype,
DiagnosticOrErrorListener, with the old implementation,
AnalysisErrorListener, and the new implementation, DiagnosticListener,
as its sole direct subclasses. Users who have implemented
AnalysisErrorListener should be able to instead implement
DiagnosticListener, and their class is an acceptable instance of
DiagnosticOrErrorListener, wherever that is needed.

In a breaking change we can drop AnalysisErrorListener and deprecate
DiagnosticOrErrorListener, and in the next breaking change, we can drop
DiagnosticOrErrorListener.

For reference, see the first API difference when deprecating AnalysisErrorListener and introducing DiagnosticListener: https://github.com/dart-lang/sdk/commit/903d77cc8229972a424941dcb7b7b79741e833eb#diff-dec15868961d7eadcd009f49d129bebcdb747aaa8dbfde5f5a08884e0cf11e32

Change-Id: I3ccf11d54b41fbca98d020d89978d250c16b4c04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436480
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-06-25 06:54:20 -07:00
Daco Harkes 2273611355 [dartdev] Organize dart --help commands into categories
This CL organizes the commands in the Dart CLI to categories. It
mirrors the categories used in `flutter --help`: `SDK`, `Project`, and
`Tools`. The available command section will now look as follows in
verbose mode:

```
Available commands:

Project
  build                 Build a Dart application including native assets.
  compile               Compile Dart to various formats.
  create                Create a new Dart project.
  pub                   Work with packages.
  run                   Run a Dart program.
  test                  Run tests for a project.

Source code
  analyze               Analyze Dart code in a directory.
  doc                   Generate API documentation for Dart projects.
  fix                   Apply automated fixes to Dart source code.
  format                Idiomatically format Dart source code.

Tools
  compilation-server    Control resident frontend compilers.
  development-service   Start Dart's development service.
  devtools              Open DevTools (optionally connecting to an existing application).
  info                  Show diagnostic information about the installed tooling.
  language-server       Start Dart's analysis server.
  tooling-daemon        Start Dart's tooling daemon.
```

Bug: https://github.com/dart-lang/sdk/issues/60980
Change-Id: Ic9da297fcdd0f8e85d619632ba8ec30fd2c32666
Cq-Include-Trybots: luci.dart.try:pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436382
Reviewed-by: Michael Thomsen <mit@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-06-25 03:08:50 -07:00
Nate Biggs c51bc84694 [dart2wasm] Add '--enable-bulk-memory' to set of features used in wasm.
This feature is required to support DataSegments in wasm which we use for large constant arrays:
https://github.com/dart-lang/sdk/blob/main/pkg/dart2wasm/lib/constants.dart#L793

Change-Id: Icda6745860da6d3f24632fc589b1796491819179
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436743
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2025-06-25 00:25:10 -07:00
Fedor Shcheglov ade10f4afb Deprecate 'Element.library2', use 'library' instead.
Deprecate `LibraryElement.loadLibraryFunction2`, use `loadLibraryFunction` instead.


Change-Id: I117fb182e6bb62c1a76b3d578c0a6d4b6f32b9c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/435920
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-06-24 17:23:11 -07:00
Nicholas Shahan 559b8552a8 [ddc,frontend_server] Fix expression compilation after recompile
Update the last known good component after a recompile reject back to
the expected state before the recompile.

Adds tests for expression compilation after recompile accept and
recompile reject cases with `--target=dartdevc`. Similar to existing
tests for the VM.

Removes calls to `_generator.accept()` and
`component.computeCanonicalNames()` from `compileExpressionToJs()`.
These were added very early in the prototype implementation and it is no
longer clear why they would be needed.

Added some additional test cases for expression compilation involving
import resolution because the change that originally added the
`component.computeCanonicalNames()` call implies it was needed for that
reason. See: https://dart-review.googlesource.com/c/sdk/+/138010

TEST=pkg/frontend_server/test/frontend_server_test.dart,pkg/dev_compiler/test/expression_compiler/expression_compiler_test.dart

Change-Id: I9c04bd46e56b33dc654d00fb330de29c3c643a5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434522
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-06-24 14:14:42 -07:00
Konstantin Shcheglov e389ceeb85 Elements. Migrate ConstructorElementToInfer to ConstructorElementMixin2 only.
Change-Id: I4a7f1dea4abbdb439dedb9e2019c42732b798e58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/436720
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2025-06-24 12:43:40 -07:00