This CL enables the primary constructors feature by default in Dart 3.13.
The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.
This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.
Currently a declaration with a constructor and some fields is written as:
```dart
// Current syntax.
class Point {
int x;
int y;
Point(this.x, this.y);
}
```
With a primary constructor, we would write the above as:
```
class Point(var int x, var int y);
```
If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:
```dart
class Point(var int x, var int y) {
this : assert(x >= 0) {
print('Point created at $x, $y');
}
}
```
As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
int x, y;
// Equivalent to Point(this.x, this.y)
new(this.x, this.y);
// Equivalent to Point.origin()
new origin() : x = 0, y = 0;
// Equivalent to factory Point.clone(Point other)
factory clone(Point other) => Point(other.x, other.y);
}
```
To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md
Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
- Added the required `wasm-opt` target for dart2wasm compiler
- Using diamonds instead of stars to be less obnoxious
- Made emoji lines the same length
- A bit louder about success cases
Change-Id: Iaa9e964d3384f5282721f1e3e5bfca2d2f84e5a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499340
Reviewed-by: Nate Bosch <nbosch@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
This change introduces `tools/build_test_fast.py`, a developer-focused
wrapper script that automatically infers and builds the *minimal* required
GN targets needed to run a specific test, avoiding the expensive overhead
of building the full SDK (e.g. `create_sdk`) during local iteration.
Features:
- Infers the correct `test.py` compiler (`-c`) from the provided test
paths (e.g., `tests/web/wasm` -> `dart2wasm`).
- Infers the correct minimal GN targets for the selected compiler.
For example, DDC tests now only build `ddc_stable_test_local` and
`create_common_sdk`, taking ~4 seconds instead of 5 minutes.
- Automatically defaults web compilers (`dart2js`, `dart2wasm`, `ddc`)
to use the `d8` runtime to prevent noisy browser popups during testing,
unless explicitly overridden.
- Synchronizes the default `mode` between `build.py` (debug) and
`test.py` (release) to prevent silent snapshot resolution failures.
- Prints clear, copy-pasteable execution commands for both the build
and test phases.
- Displays a prominent warning if a test fails, reminding the developer
to verify the minimal target mapping against `tools/bots/test_matrix.json`.
- Adds documentation for the script to `docs/Testing.md`.
Change-Id: I75473cdacca13f78dd271d9a31d5dcb15df57f6f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499043
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Fixes https://github.com/flutter/devtools/issues/9786
See go/moving-devtools-to-dart-sdk-2025.
In this change, we make the source of devtools be configurable, in
actions like build_sdk.
If `build_devtools_from_sources` is true, we build local devtools,
and if false, we continue to use the prebuilt sources.
This may be an intermediate step, while we test out building devtools
from source. Or it may be permanently be a choice, if we keep building
with CIPD.
Change-Id: I7b46d6359c69b34f316e59dccc475e211a18f965
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498640
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This CL migrates the `dwds` and `dwds_test_common` packages into the Dart SDK
repository.
Key Changes:
- Monorepo Compliance: Updated the pubspecs to align with the SDK pub workspace setup.
- Excluded `pkg/dwds_test_common/fixtures/` from `package_deps.dart`.
- Updated pkg to status to skip `dwds/test/integration/*` & `dwds_test_common/fixtures/*` until DWDS migration is complete.
- Remove package `build_daemon` from DWDS' `pubspec.yaml` as it's not approved for SDK env.
- Added `@skip_package_deps_validation` to the following files to ignore import checks for package:build_daemon: `server.dart`, `utilities.dart`, `context.dart`.
- Created `pkg/dwds/lib/src/utilities/test_path_utils.dart` to fix path resolution failures in tests (ie. `build_script_test.dart` and `ensure_version_test.dart`).
Testing:
- All tests passing locally.
- CI try bots are green.
Design Doc: http://goto.google.com/migrating-webdev and http://goto.google.com/migrating-dwds
Fixes https://github.com/dart-lang/sdk/issues/62100
Fixes https://github.com/dart-lang/sdk/issues/62101
Fixes https://github.com/dart-lang/sdk/issues/62102
Fixes https://github.com/dart-lang/sdk/issues/62103
Cq-Include-Trybots: luci.dart.try:pkg-win-release-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-linux-release-try,pkg-linux-release-arm64-try,pkg-linux-debug-try
Change-Id: I6130be8b7e0b42fbbf81b26a4950a2c4282e3a48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494660
Commit-Queue: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
I could not get the Dart script to successfully run from GN, and I
also could not find examples of the same. Everything is Python, so
Python it is.
Change-Id: I767aaf42d1584ae331d028ef073a534e5d36b77b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496402
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)
Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
When compiled to WebAssembly, the Dart SDK needs access to external
host functions to implement regular expressions, stack traces, timers
and more. Currently, `dart2wasm` relies on `js_interop` definition to
implement these functions in JavaScript.
As discussed in https://github.com/dart-lang/sdk/issues/53884, an
alternative is to use `wasm:import` annotations to let an arbitrary
embedder that doesn't necessarily run in a JavaScript context inject
implementations for these host functions.
This would allow running `dart2wasm` apps by e.g.
- using a runtime like wasmtime and defining host functions in Rust.
- defining a wrapper module implementing required functions by
delegating to WASI definitions, and then using say `wasm-merge` to
run the app in any WASI-compatible runtime.
This prepares the `--standalone` flag on `dart2wasm` to do just that.
When enabled, the compiler uses a different SDK platform to use imports
instead of JS interop. For now, these platforms are almost identical:
I've ported the timer logic to use wasm imports as a demo, but the rest
is still based on existing patch files. We can revisit in subsequent
CLs to incrementally reduce `js_interop` dependencies before removing
that library from the `dart2wasm_standalone` target entirely.
Change-Id: I3f406afbf2dab65506094de5c3f4067f4db66f3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486380
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
third_party/pkg/protobuf (and possibly others) uses a compressed reference file (.git/packed-refs) rather than the .git/refs/heads/(master|main) file expected by rev_sdk_deps.dart.
modify rev_sdk_deps.dart to use "git show-ref --verify refs/remotes/origin/main" instead.
TEST: I ran the script and it produced the expected commit hashes for both a package that uses a "main" default branch and a "master" default branch.
Change-Id: Ibe2ec2cf368d859ca78d1873f287722eb73e481b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488262
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
This change includes an initial implementation of the new VM service
implementation based on `package:dart_runtime_service`, along with the
necessary plumbing to start it in place of the legacy VM service
implementation.
The entrypoint for the new VM service implementation is located in
dart_runtime_service_vm/bin/vm_service_entrypoint.dart, which is
compiled into AppJIT and AOT snapshots when the
`--include-experimental-vm-service` flag is provided to `build.py`. To run
the VM with the new VM service implementation, the
`--experimental-vm-service` flag must be provided.
Currently, the experimental VM service implementation supports:
- User specified ports
- Authentication code flags
- Enabling the HTTP server via SIGQUIT
- Some service protocol RPCs that don't require an isolate ID (e.g.,
`getVM`)
See go/dart-runtime-services-unification for more details.
TEST=Manual
CoreLibraryReviewExempt: dart:_vmservice is private
Change-Id: I4a58cd1fa0a386313baa3d5c5345720231279123
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484820
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
This CL adds a grammar rule to Dart.g and Dart.g4 such that a
variable declaration can be `static abstract`. It also changes the rule
for `static final` and `static const` variable declarations such that
it is a syntax error if they do not have an initializing expression.
This restores the approach which was used before augmentations were
added. It is possible to do this because the added flexibility
would only allow cases which are intended to be an error, because it
is no longer possible to "override" or "extend" an implementation
in an augmenting declaration.
Change-Id: Id7696880a948697678eaf368c69c390b9c8f4e7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485440
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This CL aligns Dart.g/Dart.g4 with the feature specs for
augmentations and primary constructors such that they allow for all
kinds of membered declaration bodies to be expressed as `;`.
Change-Id: I61fe4b4fe6541fd0962f8ca39590611827c1d127
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483340
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
This sets the `experimentReleaseVersion` of `primary-constructors` to `3.12.0`. This enables tests, outside the SDK in particular, to reliably pin tests that prepare for the feature to language version 3.12.
Change-Id: I85565b9434c052398be5a7839ce5731d71162416
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482784
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Reviewed-by: Sarah Zakarias <zarah@google.com>
Removed from `benchmarks/`, `runtime/`, `sdk/`, `tools/` and `utils/`.
(Leaving `tests/`, `pkg/` and `third_party/`.)
CoreLibraryReviewExempt: No real change.
Tested: No test changes for no real code changes.
Change-Id: Ieb42441457ca3d0ea4443dd153ee902ea33b28de
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480241
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This change creates `pkg/dart_runtime_services/` with the initial
implementation of `package:dart_runtime_service`.
`package:dart_runtime_service` provides a simple interface to create
Dart services with common platform-agnostic features and behaviors,
while also allowing for configuration of custom service backends.
This initial implementation focuses on providing the initial shared
server functionality, including:
- Handlers for web socket and SSE connections
- Authentication code generation + validation
- Client management
- Initial RPC routing with two sample RPCs (getClientName, setClientName)
Change-Id: I1458269a5de7edd97120103a2c5fc2d0348eff31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478760
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
Adjust Dart.g and Dart.g4 to align them with the augmentations feature
specification and the language specification. In particular, the
handling of the keyword AUGMENT is simplified, and `topLevelDefinition`
is renamed.
Change-Id: I99dc5c6e5e3135eae14f49587d60c530e303f0e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476401
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Auto-Submit: Erik Ernst <eernst@google.com>
Moving these constants from global namespace to Page class prevents
possible conflicts with other kPageSize/kPageMask/kBlockSize constants
and allows us to export value of Page::kPageMask constant into runtime
offsets via runtime/vm/compiler/runtime_offsets_list.h.
TEST=ci
Change-Id: I4357f4644f0f5f7beba50184231fef55dd86b124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476147
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
- copy sanitizer runtime when using ubsan;
- avoid use of winnt.h CONTAINING_RECORD since it triggers ubsan "member access within null-pointer of type" error, use our copy which uses `offsetof`;
- have default virtual destructor in `ValueObject` to avoid ubsan complains about "insufficient space for an object of type 'dart:ValueObject'" at NoTemporaryAllocator use/declaration site;
- have virtual destructor in ZoneAllocated to avoid ubsan complains about "not having enough space to allocate object" at new RegExpEmpty() instantiation site;
- avoid using crashpad with ubsan as it causes dartvm to exit with error code 3;
- switch to windows, mac-friendly `[[gnu::no_sanitize(check)]]` from `__GNUC__` and `__has_feature` checks.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62267
Change-Id: I8b922a8da329af276d4cefaa88fb841cc0457124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
This shaves 4-5 seconds off of gclient runhooks (11 -> 6). There is still a single generator which takes about 5 seconds to run on its own while all the others are sub-second, otherwise this would be much faster. We may want to investigate that one as a follow-up (runtime/tests/vm/dart/generated/many_double_literals_generator.dart).
Change-Id: I5246a69ed10782d89e53b0747cd4ae1764336902
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470342
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Change the `verify_docs` package's use of `DiagnosticCode.name` to
`DiagnosticCode.lowerCaseName`. There is no functional change since
all diagnostic codes generated by the analyzer are already in lower
case.
This helps pave the way for eventually deprecating and removing
`DiagnosticCode.name`, which will help ensure that analyzer clients
treat diagnostic codes in a case-insensitive fashion.
Change-Id: I6a6a69645300e89b1bed342804d5e89ae9cf556b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468141
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This roll moves `package:record_use` to the dart-lang/native repo.
Change-Id: I31183dc8b72272d7e94ed3031ca0b8bfca583e0d
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/+/463662
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
This CL migrates the `frontend_server_client` package into the Dart SDK
repository.
Key Changes:
- Migration: Moved source code and tests into `pkg/frontend_server_client`.
- Monorepo Compliance: Updated the pubspec to align with the SDK pub workspace setup.
- Linting: Adopts `package:dart_flutter_team_lints` for analysis options and fixes associated linting errors.
- Path Resolution: Resolved package configuration and script path issues encountered in local and CI environments; see the [Workspace Tests Fixes](https://docs.google.com/document/d/1UdiRqP19qYgj-ItxDfqXSdUU6CGimiyK3BmdvjtTEyw/edit?pli=1&tab=t.0#heading=h.xfm1ezicaoik) in the design doc for implementation details.
Testing:
- All tests passing locally.
- CI try bots are green.
Design Doc: http://goto.google.com/migrating-webdev
Cq-Include-Trybots: luci.dart.try:pkg-win-release-try,pkg-win-release-arm64-try,pkg-mac-release-try,pkg-mac-release-arm64-try,pkg-linux-release-try,pkg-linux-release-arm64-try,pkg-linux-debug-try
Change-Id: Id44a701107d626df5fcd21d724980243981c7958
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461200
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Jessy Yameogo <yjessy@google.com>
I'm currently going through a process of updating the analyzer and
related packages so that their diagnostic codes are generated into top
level constant declarations in `diagnostic.dart` files rather than
static constants inside of classes like `CompileTimeErrorCode`. This
will help pave the way for unifying the treatment of diagnostic codes
between the analyzer and the CFE (since the CFE doesn't segregate
diagnostic codes into subclasses the way the analyzer does). At the
moment, both the old and the new constants exist, to allow client code
to be transitioned from one to the other.
This change transitions the references in `verify_docs.dart` over to
refer to the new top level constant declarations.
Change-Id: I6a6a6964d9a806b9b45394f2c1826fb71fbff681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462163
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Shards on vm-aot-android-debug-arm64c and vm-aot-android-debug-arm_x64
bots have been timing out recently, exceeding 1.5h testing time.
It seems like they are making progress, but number of tests is quite
large.
Increase number of shards from 10 to 16 in order to reduce running
time of each shard and avoid timeouts.
Change-Id: Id53d2cdf1eaa2606874118153c0f9c822c212daf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461840
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>