Commit Graph

56630 Commits

Author SHA1 Message Date
Paul Berry 406f493bcf Sort linter rules in developer experience analysis_options.yaml files.
https://dart-review.googlesource.com/c/sdk/+/505046 was created by an
automated script that didn't respect the ordering of lint entries in
`analysis_options.yaml` files. We usually try to keep them sorted, so
this CL re-sorts them.

Change-Id: I1a7d007af34b6db2f8e4f02b8cc71d2c6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507140
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-29 12:39:54 -07:00
Daco Harkes 1cdc6b3f84 [dartdev] dart build cli non-bin entry point and package config
Closes: https://github.com/dart-lang/sdk/issues/63432

This is needed for being able to make `package:test` being able to
compile (individual) tests with build and link hooks.

Change-Id: Icb9c576376fd04ff0518f686c00153581067b080
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-win-release-arm64-try,pkg-mac-release-try,pkg-win-release-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506242
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2026-05-29 12:11:50 -07:00
Paul Berry de28cc3a7f Fix some code generated files to point to the correct generation script.
These files had comments indicating that running
`pkg/analysis_server/tool/spec/generate_files` would regenerate them,
but that was not the case.

Change-Id: I6ceb6352edf6eab5e746276a0a2f33b16a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507521
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-29 11:15:46 -07:00
Ben Konyi 8d41c9b677 [dartdev] Synchronize environment variable modifications to fix getenv crash
Avoid a race condition between async setenv/unsetenv calls on the VM thread and concurrent getenv/environ reads on the main thread.

In glibc, setenv and getenv are not thread-safe against each other. VmInteropHandler.setEnvironmentVariable previously sent a message to the VM thread to call setenv/unsetenv asynchronously, while the main thread immediately proceeded to access Platform.environment or Platform.localeName (which calls getenv). This could cause a crash (SIGSEGV) in getenv.

This CL makes VmInteropHandler.setEnvironmentVariable synchronous by awaiting a reply from the VM thread before returning.

TEST=pkg/dartdev/test/environment_test.dart

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

Change-Id: Ic8211897ce26ffbdc142fa594cd397189a61f061
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506800
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
2026-05-29 10:26:54 -07:00
Konstantin Shcheglov 53f3ecc74d Augment. Report inconsistentInheritanceGetterAndMethod and inconsistentInheritance only on the introductory declaration.
Change-Id: I6f03031e2540b7d65995eba9608cdaf9651204e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507263
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-29 09:48:16 -07:00
Konstantin Shcheglov 67cada59b7 Augment. Don't report extra diagnostics when the executable element isAugmentationWithoutAugmentedDeclaration.
Change-Id: Ibe7c65e4ea53babfe8a308d6af310e053fe98ce2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507260
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-29 09:47:33 -07:00
Konstantin Shcheglov 88fa507348 CQ. Migrate index tests for name references to text expectations.
Change-Id: Ib5820e5e49242a29899d70b80f6aec90a5679be9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507141
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-29 08:47:12 -07:00
Brian Wilkerson 3b81982dec Fix a false positive in avoidUnusedConstructorParameters
Primary constructor parameters can be referenced in field initializers,
and the lint was failing to account for that.

Change-Id: Ib68d4a923cdbd7568be6b463d8f9f6ff1b0b682e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507201
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-29 07:41:59 -07:00
Brian Wilkerson eb5a805486 Fix a false positive for unusedElement
Constructor parameters that were only referenced by a `super` parameter
in a primary constructor were being flagged as being unused because the
`super` parameter wasn't being visited. This CL causes all `super`
parameters to be visited.

Change-Id: Iad6eee87b3b74a387d86e783e3bb35300a801c12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507262
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Brian Wilkerson <brianwilkerson@google.com>
2026-05-29 07:31:29 -07:00
Brian Wilkerson 2c8106a52c Support converting function-typed parameters to an initializing formal
This addresses a comment on a previous CL by implementing the logic
required to handle the case where the declaring parameter has an old
style function type.

Change-Id: Ie65cc379571800b0d3d5acec82341d315e80ed4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507162
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-29 06:52:08 -07:00
Jens Johansen 6a72255963 [CFE] Incremental compiler sees language version changes
Change-Id: I616abf18e85bf4898799eeb67ca34cc3c2c9d260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507323
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-05-29 06:30:15 -07:00
Johnni Winther b49f544446 [cfe][Contexts] Infer all initializers as one
This updates the resolver to infer all initializers together with the same visitor, avoiding a lot of book keeping needed to pass and compute scope provider info.

Change-Id: If30ee2b3ed4694af9c28af7a2fad3c2252fba0b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507081
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-29 05:27:03 -07:00
Johnni Winther 06e0f58562 [cfe][Contexts][InternalNodes] Add helpers for creating variables
This adds helpers for creating variables corresponding to the new variable model. This prepares for removing the LegacyVariable and only createing the variables.

This includes a fix for using the new LocalVariable for FunctionDeclaration.

Change-Id: Ib82e12ceb11cf6aa80185bdfeb559461c641dc15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506241
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-29 05:27:03 -07:00
Chloe Stefantsova 849c282e06 [cfe] Add more checks to verification of new variables
* Check that all variables are assigned a context.
* Check that the variable appears exactly once in its enclosing
contexts.
* Check that the variables can be found in their contexts.

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

Change-Id: I3ed837c538a4b9933d556cc1f9643422b75a5aa0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507120
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-29 03:52:14 -07:00
Johnni Winther 02046380d1 [cfe][Contexts][InternalNodes] Add internal nodes for FunctionNode, FunctionExpression and FunctionDeclaration
This adds internal nodes for FunctionNode, FunctionExpression and FunctionDeclaration which require InternalVariable rather than Variable. This is in preparation for using the new variable model by default.

Change-Id: I3c29954bcaae555c20b37e6a3ba1e70d959f1559
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506941
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-29 02:41:29 -07:00
Jonas Finnemann Jensen 8c42f67d35 [dartpad] Part 1-8 squashed into a single commmit.
Reviewed in https://dart-review.googlesource.com/c/sdk/+/497583

[dartpad] Part 1: Protocol and Scaffolding

This sets up folders for `package:dartpad` and `package:dartpad_worker`,

R=athom@google.com, sigurdm@google.com

including:
 * `OWNERS` files,
 * Protocol definition,
 * Exceptions, and,
 * Virtual file system utilities.

[dartpad] Part 2: HotReloadCompiler

Adds the hot reload compiler logic to dartpad_worker.

This is models on dartdevc with `--reload-last-accepted-kernel` and
`--reload-delta-kernel` options. I don't think this does an incremental
compilation, instead it does a modular compilation. Meaning, we can have
a huge collection of precompiled DDC modules and the compiler just gets
a DDC outline/summary dill files for these modules. But on the other hand
the actual code that is compiled will be recompiled on every compile()
call.

This is very important for flutter_web.js / flutter_web.dill where the
precompiled DDC modules is around 60 MB in total. The fact that
package:flutter is precompiled into flutter_web.js is critical for
compilation performance for small dartpad-style example apps.

The downside is that unlike incremental compilation with _frontendserver_,
if the user were to install package:http and use it in the app they are
compiling then every `compile()` call will recompile `package:http`.
Where as with _frontendserver_ we'd be able to invalidate specific files,
and only those would be recompiled.

This leaves future work to either:
 * (A) Add support for modular compilation to _frontendserver_, such that
   we can do incremental compilation without having to first compile all
   of `package:flutter`.
 * (B) Refactor compilation strategy implemented here, to leverage
   modular further. We could for example compile all dependencies from
   `PUB_CACHE` into a `pub_cache_outline.dill` inside the dartpad worker.
   Then recompilation would only touch the user-code. Granted this is
   still less than ideal.

At the moment the lack of incremental compilation is not a blocker,
current dartpad doesn't have incremental compilation, but granted it also
only supported a single file. This dartpad environment will support
multiple files, but adding many files will result in poor performance
until we refactor and figure out how to do incremental compilation.
Hence, why we shouldn't block progress waiting for incremental compilation
to work.

R=nshahan@google.com

[dartpad] Part 3: Pub execution wrapper

Adds the internal wrapper for executing pub commands inside the
worker's virtual file system.

R=sigurdm@google.com

[dartpad] Part 4: Language Server wrapper

Adds the internal wrapper for spawning and communicating with the
Dart LSP inside the DartPad worker.

R=scheglov@google.com

[dartpad] Part 5: DartPad Worker

Implements the main worker entrypoint, RPC message handling. The
`bin/worker.dart` is what will be compiled to WASM and will run as a
_Web Worker_.

R=sigurdm@google.com

[dartpad] Part 6: DartPad Client library

The public-facing `dartpad` library that developers use to embed
the compilation environment in their web applications.

This finishes `package:dartpad`featuring:
 * `DartPad.create()`, which creates a _Web Worker_ running the compiled
   `pkg/dartpad_worker/bin/worker.dart`, and returns a `DartPad` instance
   wrapping RPC calls into the _Web Worker_.
 * `Sandbox.createIFrame()` which creates a _sandboxed iframe_ containing
   precompiled DDC modules from the SDK assets and `sandbox.js` for
   wrapping `ddc_module_loader.js` with an RPC interface. This returns a
   `Sandbox` instance wrapping RPC calls into the _sandboxed iframe_,
   making it easy to load modules, run library entrypoints (main()),
   initiate hot-reload, or launch a flutter app.

This is an initial API design that works. There are minor inconsistencies
and improvements that we should do. But I propose that we do so in
follow-up PRs.

R=sigurdm@google.com

[dartpad] Part 7: Build Targets

Adds a `dartpad` target to the Dart SDK, which produces:
```
out/ReleaseX64/dartpad/
├── dart
│   ├── dart_sdk.js.map
│   ├── sdk.js
│   └── sdk.tar
├── ddc_module_loader.js
├── sandbox.js
├── worker.loader.js
├── worker.mjs
├── worker.support.js
├── worker.wasm
└── worker.wasm.map
```

The `dartpad/` output folder is intended to be used as `assetBaseUrl` in
client libraries provided in `package:dartpad`. And the `dartpad/dart/`
folder is intended to be used as `sdkLocation`. These files are not
intended to be distributed along side the normal Dart SDK, instead we'll
publish them on a CDN and let people use `package:dartpad` to point at
these files. If they want to self-host everything, they can copy from our
CDN or rebuild the files using a local Dart SDK checkout.

These files are also necessary for testing, to ensure that we have proper
integration tests for `pkg/dartpad_worker/`. As we will want to publish
these files on a CDN the actual compiled size in release-mode matters,
thus, we have enabled wasm optimizations steps in this mode.

R=rmacnak@google.com

[dartpad] Part 8: Tests for `package:dartpad` and `pkg/dartpad_worker/`.

We have 3 kinds of tests:
 * Unit tests (vm, browser or both),
 * Worker tests (vm and browser),
 * Integration tests (browser-only).

As the Dart SDK test runner simply executes `*_test.dart` files with
`dart` and doesn't support compiling tests to the browser, launching and
running tests in the browser, we employ `dart test` to run tests. We do
this by having `pkg/dartpad_worker/dart_test.yaml` specify that
`dart test` should look for files names `test_*.dart`, and we then create
`pkg/dartpad_worker/test/ci_test.dart´ to be a single test that simply
runs `dart test` as a subprocess. Thus, the only test file triggered by
Dart SDK test runner is `ci_test.dart`, and if you locally run `dart test`
this will run the individual `test_*.dart` files.

While this hack to use `dart test` isn't ideal it gives everyone a decent
work flow. And saves us from having to invent complex test harness for
`pkg/dartpad_worker/`.

**Worker tests** defined in `test/dart/worker/` and `test/flutter/worker/`
are all imported into `test_dart_worker.dart` and
`test_flutter_worker.dart` to reduce test compilation time. These have a
non-trivial compilation time because the worker is running in the test
process. This allows testing on VM, which can be easier to debug.

**Integration tests** unlike _worker tests_ launch the worker compiled by
the `dartpad` build target in a _Web Worker_. This has less compilation
overhead for the individual tests, but involves more setup, and can be
a bit harder to debug.

Both worker and integration tests employ `test/asset_server/` which serves
assets built by the `dartpad` build target, and serves as a pub-server for
tests. It also serves assets built by `tool/setup_local_flutter.dart`
which creates flutter assets, though this is not intended to run as part
of CI, since we do not have a Flutter checkout available. Thus, for the
time being flutter testing is local only. Maybe, later we'll move this
script to another repository.

R=sigurdm@google.com

Cq-Include-Trybots: luci.dart.try:pkg-linux-release-try,pkg-win-release-try
Change-Id: I3a99939ec5217b9f3a855fc5b9ad9699047d02cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507321
Commit-Queue: Jonas Jensen <jonasfj@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-05-29 02:25:49 -07:00
Hakim Jonas Ghoula f710c4338a [dart2wasm] Intrinsify math.min() and math.max() for double and int
Issue #55173.

Exposes signed min/max on WasmI64 and f64.min/f64.max on WasmF64 in
dart:_wasm, mirroring how WasmF64.sqrt is exposed today. The dart:math
min/max patches in math_patch.dart dispatch to them via runtime
`is`-checks, with @pragma('wasm:prefer-inline') so the inliner folds
the chain to the bare instruction sequence at each call site:

  T min<T extends num>(T a, T b) {
    if (a is int && b is int) return unsafeCast<T>((a as int).minS(b));
    if (a is double && b is double) return unsafeCast<T>((a as double).min(b));
    return _minSlow<T>(a, b);
  }

Wasm has no native i64 min_s/max_s, so WasmI64.minS/maxS emit the
same local.tee + i64.le_s/ge_s + select sequence. WasmF64.min/max emit
f64.min/f64.max directly.

The NaN- and signed-zero-aware fallback ladder is preserved in
`_minSlow` / `_maxSlow` (out-of-line, no pragma) and called for the
mixed and num cases. tests/lib/math/min_max_test.dart requires type
preservation between equal int and double arguments (e.g.
min(-499, -499.0) is int at line 113; max(499, 499.0) is int at
line 382), which a toDouble().max(toDouble()) fallback would not
satisfy.

Adds pkg/dart2wasm/test/ir_tests/math_min_max.dart covering min/max
for static int/int, double/double, mixed int/double, and num/num.
The .wat locks in f64.min/f64.max for the f64 paths, i64.le_s/i64.ge_s
+ select for the i64 paths, and `call $_minSlow` / `call $_maxSlow`
for mixed and num/num.

Measurements on a probe with four typed call sites (one each for
min<double>, max<double>, min<int>, max<int>, all marked
@pragma('wasm:never-inline')):

* .wasm size: 27,112 → 25,848 bytes (-4.66%). Generic $min and $max
  are eliminated by DCE.
* Runtime, 100M iterations per operation on d8, median of 10 runs:
  min<double> 543 → 213 ms (2.55x), max<double> 550 → 213 ms (2.58x),
  min<int>    552 →  65 ms (8.49x), max<int>    555 →  73 ms (7.61x).
  Checksums match between baseline and patched.

tests/lib/math/min_max_test.dart passes.

R=mkustermann@google.com, osa1@google.com

Change-Id: If8cf0a4df976f2d7f2230308905ff68491311c97
Bug: https://github.com/dart-lang/sdk/issues/55173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503740
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-29 00:03:32 -07:00
Jake Macdonald 06bdbd777f Update mcp-server command to be an alias for 'run dart_mcp_server@'
Strips the dart-lang/ai dependency from the SDK entirely, as well as the snapshot.

Bug: https://github.com/dart-lang/ai/issues/479
Change-Id: Id919c6a8fbf5fedeffb37e5181bc2fbd85adf986
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/507220
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2026-05-28 12:06:25 -07:00
Konstantin Shcheglov a898adf8b7 Augment. Support for abstract top-level variables and static fields.
Change-Id: Idf0ce319492c405dd06364cb6feb81e000a7c741
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506606
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-28 09:19:15 -07:00
Konstantin Shcheglov 6f804b8121 CQ. Inline _IndexMixin. Trim _IndexResult.
Change-Id: Iee776321cc5a5aad72d539dc38b6f052dccb6872
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506881
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 09:00:37 -07:00
Konstantin Shcheglov d68c1befce CQ. Replace 'late AnalysisDriverUnitIndex index' with '_IndexResult'.
Change-Id: I795224feff73eab3bca791db2feb49759cd7b888
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506900
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 08:57:32 -07:00
Konstantin Shcheglov 9543bb6472 CQ. Migrate from assertErrorsInTestResult() to resolveFileWithDiagnostics().
Change-Id: I1fc158dad37eba700b8c83e288de63270cedf3b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-28 08:52:34 -07:00
Konstantin Shcheglov f81c7f2140 CQ. Migrate from assertNoErrorsInTestResult() to resolveFileWithDiagnostics().
Change-Id: I1ec29d0051a90656092df9e321fba7f1ce2b7556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506861
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-28 08:49:28 -07:00
Konstantin Shcheglov 062a1fdcc5 CQ. Migrate to assertTestCodeWithStrictCastsDiagnostics().
Change-Id: I10858511860a8c8867ddfe0d60440bb54d4385cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506860
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 07:54:46 -07:00
Konstantin Shcheglov 1af709f3f0 CQ. Support for multi-line messages in inline expectations.
Change-Id: Iafb0f33ed1ad7167b4155e5d2c58d3db5833fae4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506820
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-28 07:50:54 -07:00
Konstantin Shcheglov c91d6d2373 CQ. Remove assertErrorsInResolvedUnit(), assertErrorsInResult(), assertNoErrorsInResult().
Update affected tests to use resolveFileWithDiagnostics() or
resolveFilesWithDiagnostics() instead.

Change-Id: I77acc47f62640ea55dc32103b526cbe489f57e6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506742
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-28 07:46:41 -07:00
Jens Johansen d441e28656 [CFE/VM] Fix mixin deleting procedure-setter because of final field
Fixes https://github.com/dart-lang/sdk/issues/63440
Tested: Tests added.
Change-Id: I0bdfd71c48ecae6094557fa4f46b8fc4b50afa73
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-05-28 05:15:07 -07:00
Lasse R.H. Nielsen 69e9d32e87 Retire 'privately-named-parameters' experiment flag.
Change-Id: I6526bd63be5f71090a3ea7f3c705778e7debf584
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Jonas Jensen <jonasfj@google.com>
2026-05-28 05:13:49 -07:00
Martin Kustermann 5423762c21 [dart2wasm] Fix unreachable instance call issue
When a call is unreachable we used to generate sometimes a block with no
outputs, but callers expected an output which they may drop. That caused
stack discipline mismatch.

Instead we should simply emit an unreachable and tell the caller there's
no value.

Issue https://github.com/dart-lang/sdk/issues/63454

Change-Id: I81be6729fd578e237c4e6483539a9d53a9ed355e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506960
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-28 03:37:13 -07:00
Robert Nystrom 6c88c6f2ba Migrate pkg/smith to the new constructor syntax.
Change-Id: I5f17f4a7eddd5dd839b2061f5d4a1f33c40703a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506661
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-27 16:54:31 -07:00
Robert Nystrom 5ccd5818e0 Migrate pkg/expect to the new constructor syntax.
Change-Id: I872868b7f9dea21889aeac00a92eef0b03849354
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506603
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-27 16:17:46 -07:00
Robert Nystrom 9f11b2fd45 Migrate pkg/status_file to primary constructors and new constructor syntax.
Unlike my previous couple of CLs, I went ahead here and also migrated
most of the classes to use primary constructors since so many of them
were small and well suited for it.

In the process, I found and fixed one bug in the assist to convert to a
primary constructor:

https://dart-review.googlesource.com/c/sdk/+/506760

So I guess this CL has already paid its way. :)

Change-Id: I9b7d08e27f4ddce3f19127aaf4f14fe627b75dab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506743
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2026-05-27 15:56:27 -07:00
Paul Berry afcfbbeba8 Migrate developer experience packages to new constructor decl syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288)

This change migrates the packages owned by the developer experience
team to use the new constructor declaration syntax, described in
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

This change was performed in an automated fashion, by (a) bumping the
packages' SDK constraints to `3.13.0-0`, (b) enabling the lints
`unnecessary_type_name_in_constructor` and
`unnecessary_const_in_enum_constructor`, (c) fixing the resulting lint
failures using `dart fix`, and then (d) reformatting the affected
files.

To ease code review, I've reverted unrelated formatting changes.

Since this change requires bumping SDK constaints to `3.13.0-0`, it
was only performed on packages that are *not* published on
pub. (Packages that *are* published on pub should remain on lower
language versions until at least after the stable version of 3.13 is
released, so that we don't block users on the stable channel from
receiving updates to those packages.)

Change-Id: Ibb4daebafd239da58251e838ea6a3f336a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505046
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-27 14:52:58 -07:00
Robert Nystrom 1e5aebc601 Reformat pkg/status_file.
I was starting to migrate it to use primary constructors but realized
the formatting was out of date, so I figured I may as well fix that
first so that the migration CL is easier to read.

There are no changes in this CL, I only ran `dart format .`.

Change-Id: I25f772ce0e0a00d83f1f8b561fc8bb9fe9486859
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506741
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-27 14:43:43 -07:00
Brian Wilkerson 8b555128be Support converting a declaring param to an initializing param
Server already supports the opposite, so this just makes it possible to
go both ways.

This doesn't support converting a declaring function typed parameter.
We could add that, but I'm hoping it's rare enough to not be worth doing.

Other than that, I think I've covered all the cases, but please pay
special attention to the test coverage.

Change-Id: I400204ca820d0e0f1cc44075dd54946db79b2115
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506740
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 14:39:09 -07:00
Paul Berry 8b66930364 [presubmits] Print stdout,stderr if CheckSorted result can't be parsed.
Previously, in the `CheckSorted` presubmit check, if
`verify_sorted_test.dart` returned a nonzero exit code but none of its
output lines contained the string `Unsorted file`, then a presubmit
failure would be generated containing an empty string, resulting in
confusing output like this:

    Running presubmit upload checks ...
      18.4s to run CheckChangeOnUpload from /home/paulberry/dart1/sdk/pkg/_fe_analyzer_shared/PRESUBMIT.py.
    ** Presubmit ERRORS: 1 **


    Presubmit checks took 21.4s to calculate.
    There were presubmit errors.

This might happen, for example, if `verify_sorted_test.dart` contained
a compile-time error or threw an unhandled exception.

With this change, the message is `CheckSorted: could not parse output
of verify_sorted_test.dart`, followed by the full stdout and stderr
from the attempt.

This should make this sort of failure a lot easier to debug.

Note: I've made this same fix before to
`pkg/_fe_analyzer_shared/PRESUBMIT.py` (see
https://dart-review.googlesource.com/c/sdk/+/485601). I didn't realize
at the time that the code was duplicated.

Note: This should make it easier to debug
https://github.com/dart-lang/sdk/issues/63464.
Change-Id: I4892dcff7ad6969ca40564c1fd7e62e36a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506605
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 14:34:26 -07:00
Konstantin Shcheglov d3a8da96a0 Augment. Rename two tests in augmentation_return_type_mismatch_test.dart
Change-Id: I1a694006a2f34951298eb6d8846c44d88a0ef391
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506502
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 14:13:43 -07:00
Konstantin Shcheglov 5252e5e3d3 CQ. Remove assertErrorsInFile2(), use resolveFilesWithDiagnostics().
Add helpers that resolve non-test files using the same inline diagnostic
expectation format as resolveTestCodeWithDiagnostics.
resolveFileWithDiagnostics handles a single file, while
resolveFilesWithDiagnostics writes all related files before resolving
any of them.

Add multi-file diagnostic expectation generation so context messages in
one file can be referenced from diagnostics reported in another. Teach
expectation updating how to target values in a files-to-code map using
per-entry intra-invocation ids.

Remove assertErrorsInFile2 and migrate diagnostics tests from
hand-written ExpectedError offsets to inline markers. This keeps the
diagnostic range, code, message, and cross-file context next to the code
under test, and makes expectation updates reusable for library and part
tests.

Initialize strong-mode type assertions from resolveFile so callers that
resolve files other than testFile get the same setup.

Change-Id: Ie492155b046c28a535faf21fa9a2e47797caffb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506180
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-27 14:05:36 -07:00
Robert Nystrom 2cd3ec552c Fix "Convert to a primary constructor" on generic classes.
It would incorrectly put the primary constructor parameter list before
the type's type parameter list, like:

```dart
// Before:
class C<T> {
  C();
}

// After:
class C()<T> {
}
```

This fixes it to follow the type parameter list if there is one.

Change-Id: Ib49c7df7923e9feed11f87579fefc8300c56c4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2026-05-27 13:59:34 -07:00
Paul Berry 9bd89a769d Work around issue with -r in presubmit scripts.
For some reason, when a `CheckSorted` presubmit invokes
`verify_sorted_test.dart`, the `-r` flag is preventing the compiler
from picking up the proper language version from
`.dart_tool/package_config.json`. This is interfering with my ability
to run presubmits for
https://dart-review.googlesource.com/c/sdk/+/505046.

See https://github.com/dart-lang/sdk/issues/63464 for additional
details.

As a temporary workaround, this CL removes the `-r` flag. It should be
reverted once https://github.com/dart-lang/sdk/issues/63464 has been
fixed (and the pre-built SDK has been updated to include the fix).

Change-Id: Ibc48eec4ef382d6afe17d73454f07dcd6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506700
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-05-27 13:49:54 -07:00
Sam Rawlins d0f27293ce DAS plugins: Respect the analysis roots set by "dart analyze"
Work towards https://github.com/dart-lang/sdk/issues/62686

`dart analyze` uses an 'analysis.setAnalysisRoots' "command" to let
the analysis server know that the user requested, for example,
`dart analyze foo` or `dart analyze foo/bar.dart`. This was not conveyed
to analyzer plugins, so analyzer plugins will always analyze the entire
context collection.

(For some reason, only files in the "analysis roots" were reported in
stdout; maybe DAS or dartdev does its own filtering on diagnostics.)

This change forwards the `setAnalysisRoots` request to DAS plugins using
a new protocol message that mirrors the one for the server.

We should not change the behavior of `analysis.setContextRoots` for
legacy plugins, so we keep sending that request as per usual. Then
we send `analysis.setAnalysisRoots` at the same time.

If we receive an `analysis.setAnalysisRoots` message, dispose and
delete references to the existing context collection, and instantiate
a new one, with the specified `included` and `excluded` paths.

Change-Id: I53627da1c30351a22b5e5410a557bf486620a7aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505041
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 13:47:02 -07:00
Robert Nystrom 81059a1b79 Migrate pkg/scrape to the new constructor syntax.
Change-Id: I45dcedb1ce90d7a9700a57767ae01fff5721ccfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506602
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2026-05-27 12:21:23 -07:00
Konstantin Shcheglov ba760c36a4 Augment. Report augmentationInducedGetterAlreadyComplete and augmentationInducedSetterAlreadyComplete.
Change-Id: I87ba9c5b6c489417173a387bded700f52b52e7ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506501
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 11:17:44 -07:00
Sam Rawlins 19ca914f74 Remove redundant lint rules
use_null_aware_elements is included in the lints package analysis
options.

Change-Id: I01222fc7e84be32da657f04b16e15af7d5861433
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-27 10:26:22 -07:00
Paul Berry 49597f85d9 [front_end,kernel] Add ignores for codegen to prepare for new syntax.
(Part of https://github.com/dart-lang/sdk/issues/63288)

Updates various code generators in the `front_end` and `kernel`
packages to output `ignore_for_file` comments to ignore the
`unnecessary_type_name_in_constructor` lint.

This is a first step towards migrating the `front_end` and `kernel`
packages to use the new constructor declaration syntax, since it will
allow the `unnecessary_type_name_in_constructor` lint to be enabled
without breaking generated code.

Once all the packages have had their SDK constraints bumped to a
language version that supports the new syntax, I'll update the code
generator to use the new syntax, and remove the ignores.

For more information about the new constructor declaration syntax, see
https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md#abbreviations-of-in-body-constructor-declarations.

Change-Id: I73fd960a7eea2a1a59316602c49d56816a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506380
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-05-27 10:11:50 -07:00
Sam Rawlins 0fa39c9649 linter: Switch cascade_invocations to report once for a set of cascadable statements
Fixes https://github.com/dart-lang/sdk/issues/58688

Change-Id: I022b58109deedfbd6e57e6aa5159942081e6d8fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503941
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-05-27 08:58:12 -07:00
Daco Harkes da40aec0bb [deps] Roll dart-lang/native
Pass in the entry-points and OS to the link hook when the record_use
file is provided. So that different target OSes and different entry-
points are cached separately.

Also, commit skill to rev `native_rev` in DEPS. (The new agent
IDE ignores gemini.md that contained it and prefers using skills.)

Change-Id: Ic77e3ccd5915736081c01f8b75901f626f688f19
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-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,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506580
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
2026-05-27 07:31:46 -07:00
Erik Ernst 3263555dc5 Start implementation of anonymous block methods
This CL introduces support for anonymous block methods (that is,
`e.{ print(this); }` as opposed to `e.=> print(this);`). It introduces
the notion of a `ReturnContext` which is used to change the semantics
of a return statement when it returns from an anonymous method (where
it works like a `break` that terminates the execution of the block
which is the body of the enclosing anonymous method), but keeps the
semantics of return statements returning from a function (including
function literals) still have the same semantics as today.

Change-Id: I404459361fbb7c2e495e46d1bd29924063f3aac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503800
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-05-27 06:04:46 -07:00
Jens Johansen b59608241f [CFE] Scope calculator handles parameters and initializing formals special
* The VM stops at the last parameter at which point the last parameter
   should also (pretend) to be in scope.
 * We should have initializing (super) formals in scope in the parameter
   list and in the initializer list but not in the body.

Small step towards https://github.com/dart-lang/sdk/issues/62645

Change-Id: I94442e1709a2e14613d81617f8153d9e2b11d889
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500460
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-05-27 02:49:19 -07:00
Jens Johansen b69989fa35 [CFE] Incremental suite: Do more equality testing
Change-Id: I2e4ebf9d12a8cae0481bf2a7022d4fa801fcf4fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505821
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-27 01:33:47 -07:00