Kallen Tu
8bfb683892
Enable 'primary-constructors' feature flag.
...
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 >
2026-05-04 15:09:49 -07:00
..
2026-05-04 15:09:49 -07:00
2026-04-29 08:10:43 -07:00
2026-03-31 15:36:18 -07:00
2026-04-20 10:28:01 -07:00
2025-02-26 14:01:44 -08:00
2026-02-04 10:16:41 -08:00
2026-02-04 10:16:41 -08:00
2025-07-08 02:36:10 -07:00
2026-04-21 10:13:04 -07:00
2026-02-04 10:16:41 -08:00
2026-03-26 08:21:00 -07:00
2025-11-10 02:29:41 -08:00
2026-02-04 10:16:41 -08:00
2024-08-28 08:52:19 +00:00
2026-01-28 10:27:29 -08:00
2026-02-04 10:16:41 -08:00
2026-02-27 07:43:14 -08:00
2026-04-27 09:42:38 -07:00
2026-04-10 06:15:22 -07:00
2026-03-18 10:18:06 -07:00
2026-03-18 10:18:06 -07:00
2026-03-31 19:59:09 -07:00
2026-04-16 04:25:37 -07:00
2026-03-02 07:55:38 -08:00
2026-02-23 09:54:47 -08:00
2026-02-23 09:54:47 -08:00
2026-04-16 04:25:37 -07:00
2026-04-16 04:25:37 -07:00
2026-04-13 10:10:42 -07:00
2024-10-24 03:24:08 +00:00
2026-03-02 08:13:26 -08:00
2026-03-02 07:55:38 -08:00
2026-05-04 15:09:49 -07:00
2026-02-04 10:16:41 -08:00
2026-02-04 10:16:41 -08:00
2025-07-29 12:54:49 -07:00
2026-01-29 13:18:24 -08:00
2025-07-29 12:54:49 -07:00
2025-10-07 10:44:02 -07:00
2025-10-07 10:44:02 -07:00
2025-07-29 12:54:49 -07:00
2026-01-29 13:18:24 -08:00
2025-07-29 12:54:49 -07:00
2026-01-29 13:18:24 -08:00
2025-09-12 04:19:40 -07:00
2025-10-07 10:44:02 -07:00
2025-10-01 09:41:26 -07:00
2026-04-10 06:15:22 -07:00
2026-04-10 06:15:22 -07:00
2026-04-10 06:15:22 -07:00
2026-02-19 09:43:52 -08:00
2026-04-10 06:15:22 -07:00
2025-11-18 14:33:11 -08:00
2026-04-20 17:46:32 -07:00
2026-04-10 06:15:22 -07:00
2025-06-18 13:07:22 -07:00
2025-06-18 13:07:22 -07:00
2025-06-18 13:07:22 -07:00
2025-06-18 13:07:22 -07:00
2024-12-04 14:36:46 +00:00
2026-05-04 15:09:49 -07:00
2026-04-29 15:36:54 -07:00
2026-03-31 12:55:51 -07:00
2026-04-08 15:26:06 -07:00
2026-03-24 11:26:23 -07:00
2026-03-31 12:55:51 -07:00
2026-03-31 12:55:51 -07:00
2026-04-29 15:36:54 -07:00
2026-03-31 12:55:51 -07:00
2025-11-19 07:45:52 -08:00
2025-11-21 06:42:16 -08:00
2024-08-19 21:46:26 +00:00
2025-07-29 12:54:49 -07:00
2025-07-29 12:54:49 -07:00
2025-06-12 20:46:54 -07:00
2025-07-29 12:54:49 -07:00
2025-07-29 12:54:49 -07:00
2026-03-26 08:21:00 -07:00
2026-02-18 09:18:10 -08:00
2026-04-10 06:15:22 -07:00
2026-04-10 06:15:22 -07:00
2026-02-04 10:16:41 -08:00
2026-02-04 10:16:41 -08:00
2026-02-17 14:14:59 -08:00
2025-06-17 06:22:15 -07:00
2026-02-04 10:16:41 -08:00
2026-02-04 10:16:41 -08:00
2026-02-04 10:16:41 -08:00
2025-05-27 06:30:20 -07:00
2026-05-04 15:09:49 -07:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2026-05-04 15:09:49 -07:00
2026-05-04 15:09:49 -07:00
2026-04-29 15:36:54 -07:00
2026-05-04 10:45:15 -07:00
2026-05-04 10:45:15 -07:00
2026-05-04 10:45:15 -07:00
2026-03-04 12:40:19 -08:00
2026-03-04 12:40:19 -08:00
2026-02-23 09:54:47 -08:00
2025-12-01 16:15:39 -08:00
2025-12-01 16:15:39 -08:00
2024-08-15 14:09:52 +00:00
2026-04-14 17:22:31 -07:00
2026-02-04 10:16:41 -08:00
2025-05-05 15:21:13 -07:00
2026-02-25 04:48:51 -08:00
2026-02-25 04:48:51 -08:00
2026-04-22 10:30:04 -07:00
2026-02-04 10:16:41 -08:00
2026-01-29 13:18:24 -08:00
2025-10-01 10:06:20 -07:00
2026-01-29 13:18:24 -08:00
2025-10-01 10:06:20 -07:00
2026-01-29 13:18:24 -08:00
2025-10-01 10:06:20 -07:00
2025-09-15 10:00:29 -07:00
2026-04-10 06:15:22 -07:00
2026-04-10 06:15:22 -07:00
2025-07-15 09:29:41 -07:00
2025-07-21 14:56:01 -07:00
2026-02-18 09:18:10 -08:00
2026-03-04 12:40:19 -08:00
2026-04-29 15:36:54 -07:00
2026-04-08 15:26:06 -07:00
2026-04-20 10:28:01 -07:00
2026-04-20 10:28:01 -07:00
2024-12-04 14:36:46 +00:00
2025-09-10 06:37:12 -07:00
2026-03-09 03:36:55 -07:00
2026-04-29 15:36:54 -07:00
2026-04-27 08:53:18 -07:00
2026-03-02 07:55:38 -08:00
2025-11-24 01:38:20 -08:00
2025-07-15 09:29:41 -07:00
2025-06-10 12:15:25 -07:00
2025-06-10 12:15:25 -07:00
2025-06-10 12:15:25 -07:00
2026-01-21 10:59:51 -08:00
2026-01-21 10:59:51 -08:00
2026-01-27 09:14:39 -08:00
2026-02-18 09:18:10 -08:00
2025-02-26 14:01:44 -08:00
2025-02-26 14:01:44 -08:00
2026-04-08 14:17:21 -07:00
2025-11-19 07:45:52 -08:00
2026-04-20 10:28:01 -07:00
2026-04-20 10:28:01 -07:00
2026-04-20 10:28:01 -07:00
2026-03-04 12:40:19 -08:00
2026-04-20 10:28:01 -07:00
2026-04-20 10:28:01 -07:00
2026-04-20 10:28:01 -07:00
2025-01-22 07:48:37 -08:00
2025-01-22 07:48:37 -08:00
2025-05-13 14:29:37 -07:00
2025-05-13 14:29:37 -07:00
2026-04-28 05:45:31 -07:00
2025-11-21 06:42:16 -08:00
2025-08-11 13:41:12 -07:00
2026-04-07 08:06:43 -07:00
2024-08-19 21:46:26 +00:00
2026-02-17 14:25:39 -08:00
2025-06-03 10:36:23 -07:00
2024-09-18 21:07:59 +00:00
2024-09-18 21:07:59 +00:00
2026-03-04 16:07:20 -08:00
2026-04-10 06:15:22 -07:00
2025-06-02 10:04:39 -07:00
2026-04-21 04:02:25 -07:00
2024-09-25 17:28:44 +00:00
2025-07-07 17:02:17 -07:00
2024-08-28 16:41:50 +00:00
2025-07-28 13:32:36 -07:00
2026-03-24 10:23:38 -07:00
2026-02-04 10:16:41 -08:00
2026-03-02 13:52:34 -08:00
2026-04-10 06:15:22 -07:00
2026-05-04 15:09:49 -07:00
2026-04-29 08:06:40 -07:00
2026-04-28 15:51:33 -07:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2026-04-07 08:06:43 -07:00
2026-03-25 11:58:38 -07:00
2026-03-25 11:58:38 -07:00
2025-05-21 01:36:22 -07:00
2026-01-27 09:14:39 -08:00
2026-02-23 09:54:47 -08:00
2026-04-10 06:15:22 -07:00
2026-02-25 04:48:51 -08:00
2024-09-12 15:16:12 +00:00
2026-04-08 15:26:06 -07:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2026-04-14 17:22:31 -07:00
2026-02-04 10:16:41 -08:00
2026-04-28 15:51:33 -07:00
2026-04-15 09:37:41 -07:00
2026-04-14 17:22:31 -07:00
2026-02-04 10:16:41 -08:00
2025-10-07 15:13:14 -07:00
2025-10-07 15:13:14 -07:00
2026-04-21 04:02:25 -07:00
2026-04-21 04:02:25 -07:00
2026-04-28 15:51:33 -07:00
2026-04-21 10:13:04 -07:00
2026-04-14 04:26:01 -07:00
2025-08-04 14:05:01 -07:00
2025-09-15 10:00:29 -07:00
2026-04-08 15:26:06 -07:00
2026-04-29 08:06:40 -07:00
2026-02-23 09:54:47 -08:00
2026-04-14 04:26:01 -07:00
2026-03-18 10:18:06 -07:00
2026-01-27 09:14:39 -08:00
2026-04-08 14:31:16 -07:00
2025-04-24 11:07:56 -07:00
2025-04-14 07:36:31 -07:00
2026-04-29 15:36:54 -07:00
2026-03-26 08:21:00 -07:00
2026-04-30 17:04:19 -07:00
2026-03-24 10:23:38 -07:00
2026-01-14 03:53:04 -08:00
2025-06-18 13:07:22 -07:00
2025-06-18 13:07:22 -07:00
2026-01-14 03:53:04 -08:00
2026-05-04 10:45:15 -07:00
2026-03-18 10:18:06 -07:00
2026-04-15 15:23:51 -07:00
2024-11-26 19:24:31 +00:00
2026-03-04 12:40:19 -08:00
2026-04-15 15:23:51 -07:00
2026-04-13 14:00:21 -07:00
2025-06-18 13:07:22 -07:00
2025-06-18 13:07:22 -07:00
2026-04-29 15:36:54 -07:00
2025-11-21 06:42:16 -08:00
2025-11-19 07:45:52 -08:00
2026-02-04 10:16:41 -08:00
2026-04-30 01:05:23 -07:00
2026-04-27 08:53:18 -07:00
2025-10-01 09:51:59 -07:00
2026-02-04 10:16:41 -08:00
2024-08-15 14:09:52 +00:00
2026-05-04 15:09:49 -07:00
2025-12-12 06:44:20 -08:00
2026-04-08 15:26:06 -07:00
2025-11-21 06:42:16 -08:00
2024-08-15 14:09:52 +00:00
2026-04-10 06:15:22 -07:00
2026-04-28 15:51:33 -07:00
2026-04-08 15:26:06 -07:00
2026-04-27 09:42:38 -07:00
2026-03-31 12:55:51 -07:00
2026-03-31 12:55:51 -07:00
2026-02-23 13:01:19 -08:00
2025-08-25 14:43:41 -07:00
2025-08-25 14:43:41 -07:00
2026-01-14 03:53:04 -08:00
2025-12-01 12:47:18 -08:00
2025-10-27 11:17:38 -07:00
2026-01-07 12:47:21 -08:00
2025-10-24 04:34:01 -07:00
2026-01-20 05:58:38 -08:00
2026-01-20 05:58:38 -08:00
2024-09-12 15:16:12 +00:00
2025-02-24 10:44:28 -08:00
2025-05-12 12:32:19 -07:00
2025-05-23 07:23:22 -07:00
2025-02-24 10:44:28 -08:00
2024-12-17 13:30:50 -08:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2025-08-25 14:43:41 -07:00
2026-04-29 15:36:54 -07:00
2026-04-29 08:10:43 -07:00
2025-05-27 06:30:20 -07:00
2026-04-29 15:36:54 -07:00
2026-04-06 10:35:42 -07:00
2026-03-03 06:58:35 -08:00
2026-03-03 06:58:35 -08:00
2026-01-27 09:14:39 -08:00
2026-01-27 09:14:39 -08:00
2025-10-20 15:58:20 -07:00
2025-09-24 13:14:32 -07:00
2025-10-20 10:49:20 -07:00
2025-06-30 15:50:40 -07:00
2026-02-17 14:14:59 -08:00
2025-10-14 13:15:21 -07:00
2026-04-29 15:36:54 -07:00
2025-05-23 06:19:16 -07:00
2025-05-23 06:19:16 -07:00
2025-05-23 06:19:16 -07:00
2026-02-17 14:14:59 -08:00
2026-02-04 10:16:41 -08:00
2025-06-18 13:07:22 -07:00
2024-08-07 12:59:35 +00:00
2026-01-28 13:49:00 -08:00
2026-05-04 10:45:15 -07:00
2026-01-28 13:49:00 -08:00
2026-01-28 13:49:00 -08:00
2026-01-13 14:28:00 -08:00
2026-05-04 10:45:15 -07:00
2026-05-04 10:45:15 -07:00
2025-07-07 17:02:17 -07:00
2026-03-31 12:55:51 -07:00
2026-02-04 10:16:41 -08:00
2024-08-07 12:59:35 +00:00
2026-02-23 09:54:47 -08:00