Commit Graph

2526 Commits

Author SHA1 Message Date
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
Johnni Winther a04691a8a8 [kernel][Contexts] Serialize new local variables
This adds serialization of the new local variables, VariableStatement and VariableDeclaration. This prepares for replacing LegacyVariable with the new variables in all backends.

TEST=existing

Change-Id: I9bbebfbfd372042d6b7027f0fabd24c165699832
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/506240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-27 00:41:34 -07:00
Johnni Winther 5111553828 [kernel][Contexts] Add LateVariable
This adds a separate node for late variables, allowing for specializing its interface.

Change-Id: Id83308ce8bb2e36e5fe23adb201859af1275897f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505840
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-27 00:41:34 -07:00
Johnni Winther f9fadc80da [cfe][Contexts] Remove constant evaluator work-around
Closes #63414

Change-Id: Iac2cd204d70138676ece9d8d438f1a5f01c1bad4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505820
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-27 00:41:34 -07:00
Johnni Winther 6b693e00bc [kernel][Contexts] Add VariableDeclaration
This adds a VariableDeclaration node which is used in ForStatement instead of VariableStatement.

This is a step towards removing the initializer from Variable. Long term, VariableDeclaration will own the initializer expression for variables and function parameters will have a defaultValue property instead of using the initializer property for the default value.

TEST=existing

Change-Id: I4a663eeb6006a0f9f098fb2b3e3b502d2ae583b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505681
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2026-05-27 00:41:34 -07:00
Erik Ernst 945978f5c0 Change code generation for dart2js to enable capturing
This CL changes the code generation for `dart2js` (and not for any other
backend) such that the variable holding the receiver of an anonymous
method invocation is declared as a normal local variable rather than
being a `Let` variable. This is needed because `dart2js` supports
capturing the former, but not the latter.

Change-Id: I054805f7006306186f2c6dfe36d7162b42293ae1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503420
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-21 04:22:30 -07:00
Johnni Winther d18803c5be [kernel][Contexts] Move initializer from VariableInitialization to Variable
This is a step back towards the end goal of separating Variable its initializer. This is done in order to normalize the encoding between the old and the new variable model, such that the split can be perform in both the old and new model simultaneously.

TEST=existing

Change-Id: I3ad6595613c06812d95dff3cabbca6eb05dc1c98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/505000
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-21 01:51:10 -07:00
Johnni Winther a1fec21b8a [kernel][Contexts] Move LegacyVariable to variables.dart
Change-Id: I84212013824a79772f80c60245155129e3422e01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504220
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-21 01:51:10 -07:00
Johnni Winther 80c9d57250 [kernel][Contexts] Rename VariableDeclaration to Variable
This is a step towards split variables from their declarations as part of encoding variables and their usage more precisely.

TEST=existing

Change-Id: I4a0eeb2947bdebce3667afda4e6cfbfdf5d7de18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504201
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
2026-05-21 01:51:10 -07:00
Simon Binder ff25d85758 [dart2wasm, standalone] Rename JSStringImpl to EmbedderStringImpl
The standalone target used `JSStringImpl` as the name for its string
implementation even though JavaScript isn't involved in that at all.
This was to simplify parts of the compiler which can then refer to both
classes with the same name.

Changing this in the compiler is not that complicated however, so it
makes sense to align the string implementation name with the embedder
terminology we also use for other host imports.

TEST=pkg/dart2wasm/test/ir_tests/standalone.{dart,wat}

Change-Id: I1e112c8a72bb43a7edfa73ff7205d353edc7403a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504581
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-21 01:35:53 -07:00
Chloe Stefantsova 10dd51ee4c [cfe] Verify new variables have contexts
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I01295904c8fd5f76574e8979eb40e4cd174f9e09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504202
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-05-19 04:29:29 -07:00
Johnni Winther e30cd0322c [cfe][Contexts] Split VariableDeclaration and VariableStatement
This separates VariableDeclaration from Statement. VariableDeclaration no longer implements Statement and variable declared in a block or in a for-statement are now wrapped by a VariableStatement.

Currently there are two VariableStatement implementations; LegacyVariableStatement for variables in the current model, called LegacyVariable, and VariableInitialization for variables used in the new, still experimental, encoding that supports scope computation.

This CL is a step towards realigning the AST nodes to the new model in which each kind of variable has its own distinct subclass. (LocalVariable, PositionalParameter, NamedParameter, SyntheticVariable, etc.)

Note that it is not the intent to use VariableStatement in ForStatement going forward but that will be handled in a follow-up.

TEST=existing.

Change-Id: I5b309cd62c9b138f95b74fb054686edffa49a393
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502681
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-18 05:49:28 -07:00
Johnni Winther 119d9d72b7 [cfe][InternalNodes] Use internal/external helpers to create AST nodes
This replaces the creation of many AST nodes with calls to either the internal or external helpers, to help enforce passing of needed arguments, in particular file offset which are generally not required.

Change-Id: Id9b2449f398492dd5fb8bf0c71fbe3ec04444c95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497842
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-13 02:11:33 -07:00
Chloe Stefantsova 999f8d4ff6 [cfe] Make Scope and VariableContext data objects, not TreeNodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ie4f244433c320c3a72e8769034526e438dc6406c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502682
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-05-13 01:40:28 -07:00
Johnni Winther 756dd1c665 [cfe] Use required type for lookup in map/list pattern
The members used to match a map/list pattern should be pulled from the required type and not the matched type in order to avoid wrongfully using extension type members.

Closes #63315

Change-Id: Idccc19fad1a3fc5cd1ecac2cfdb0ef0ee431d50f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502700
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-12 05:08:33 -07:00
Chloe Stefantsova 09a156bb2d [cfe] Make VariableBase.context independent from VariableBase.parent
Previously the getter VariableBase.context was redirecting to
VariableBase.parent, effectively requiring a change of the ownership
over the variable. This CL makes VariableBase.context a field of
VariableBase, allowing for the previously existing ownership structure
of the AST tree nodes.

The change allows to avoid workarounds for the existing
ownership-restoring logic, such as the assignments to the `parent`
pointer made in the constructors of the AST nodes and their
`transformChildren` and `transformOrRemoveChildren` methods.

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

Change-Id: I307c9d2b23c8201f8d7d2a100acf9fb8f3af2572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494441
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-12 00:08:47 -07:00
Chloe Stefantsova 7d2b344a7e [cfe] Fix printing of catch clauses with new CatchVariables
Since `CatchVariable`s don't have initializers, the print method in
the `Catch` node shouldn't attempt to print it.

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

Change-Id: I548e80e0f95c20a0537392faccd5c1fc11d844d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 04:46:43 -07:00
Chloe Stefantsova 8df966741d [cfe] Update ast printing of new variable nodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I36f968d4dffc523af8e4f4c993d59b1b914110d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501641
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 04:46:26 -07:00
Johnni Winther c2787e1cf4 [cfe][Contexts] Flatten variables hierarchy
This removes the LegacyVariableDeclaration and VariableInitializationBase classes to create a simpler hierarchy. This is done preparation for splitting variables from statements.

TEST=existing

Change-Id: If29c9eee1e3d8bed819ce53ed178c3efa3bffaea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501961
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 00:38:41 -07:00
Johnni Winther 6a6f59f715 [cfe][InternalNodes] Move for-in lowering to inference visitor
This adds internal nodes for the encoding of various versions of for-in loops and moves the lowering to be performed as part of the inference. This avoids the need to create lowered and external AST nodes directly during body building.

Change-Id: If559bc19ff9e6aacb457413c71956c18eae2a4b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499542
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-07 00:15:24 -07:00
Johnni Winther a128973291 [cfe] Use identical in subtype check
This improves the subtype check by ~27%. Using subtype_measure.dart the
test result was: TTestResult[significant: -27.74% +/- 2.03% (-34846.20 +/- 2548.23) (at least -32297.97)]

Change-Id: I908fe8807f7b265c59f6e5f83e3e8a444eb11743
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387965
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-01 05:49:45 -07:00
Jens Johansen 18b76c4567 [kernel/CFE] Move dart_scope_calculator to CFE
Wanting to use for instance "extractLocalName" from the front_end it can
no longer stay in kernel.

Change-Id: I8dec4d187cdfbc8a50a2a997fa3a3db9adb0786a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498900
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 23:21:58 -07:00
Kilian Schulte 9e8fdef17c Add annotation-based creation location tracking
Closes https://github.com/dart-lang/sdk/pull/63011

GitOrigin-RevId: 926534c2f5d3cd1e9629cf25f6b028ab34c00e64
Change-Id: I88460a060faabeae8f611e88f23b2eb5fc99f21a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491702
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2026-04-28 03:06:03 -07:00
Nate Biggs 3d2d6492c1 Add 'external-effect' pragma support to all the backends.
Call sites targeting a procedure annotated with `external-effect` will
not produce any code, including the argument which will not be
evaluated.

However, the single parameter will be treated as 'live' for the purposes
of any global analysis the backends do. This is useful for things like
protobuf shaking where a user may want to retain certain protobuf
messages without actually emitting the code that retains those messages.

Today this functionality is available internally in the vm and wasm SDK
libraries. dart2js has similar functionality represented via the
opaqueTrue and opaqueFalse booleans (which will cause conditional
branches to get shaken after analysis). This will replace dart2js's
opaque(True/False).

This also adds validation to the frontend to ensure a method annotated
with 'external-effect' is well-formed.

Change-Id: If1c4096673e655c58fe7638840a16125003e7809
Tested: Backend tests for codegen were added. A frontend test was added for the validation. A language test was added to confirm the behavior.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/476020
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-27 09:42:38 -07:00
Jens Johansen 41aa8d42bc Reapply "[kernel/cfe/etc] Split outline transformation into performOutlineTransformations and performOutlineComponentOperations"
This reverts commit 264098c85f.

Currently outline transformations aren't run via the incremental
compiler which causes problems in
https://dart-review.googlesource.com/c/sdk/+/491702 which fixes it by
calling the current transformation in the incremental compiler. This
calls it twice though (because it's run again in
`frontend_server/lib/compute_kernel.dart`, but removing it there doesn't
work because a filtering is done which doesn't apply through the
incremental compiler.

This CL splits up the outline transformation stage into a call that can
actually transform the libraries and one that can do the filtering,
which should fix the issue.

Original CL was reverted because it caused errors in google3. The
original CL is in patchset 1. The error has been reproduced and
recreated in a test added in patchset 2. The fix is in patchset 3.

The dwds failure @
https://github.com/dart-lang/webdev/actions/runs/24516059718/job/71660245069
has been verified as fixed as well.

The problem was this:

Previously outline transformations were not run by the incremental
compiler, but only outside. When it was moved to the incremental
compiler it had on old - outdated - `target` which for the ddc/dart2js
summary target would hold a list of source files that it was initially
created with, not the ones currently being compiled. This meant that the
transformation step that removed "unrelated" libraries actually removed
the newly compiled libraries instead. It could cause one of two issues:
1) Empty output: With no overlap between the combined output of the
   compile and the sources of the first compile (i.e. the ones in the
   outdated `target`) all libraries were filtered out. If a later
   compile was given this as a summary input the compile could fail with
   a file not found error because the given summary - which should
   contain the missing library didn't.
2) Non-empty output: With an overlap between the combined output of the
   compile and the sources of the first compile only the overlap would
   be included. In practise this would mean that the output would be a
   (potentially partial) copy of the first compile. If then a later
   compile was given both the summary from the first compile and the
   output with the copy it would throw when loading because it got the
   same library from two different summaries.

Change-Id: If712663acdbd7d25ccb3beab54a7efac0c0b0568
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496181
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-04-21 23:26:41 -07:00
Chloe Stefantsova fac280bd7e [cfe] Add ScopeProvider as an interface of Field
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I8a9cb883181a584ceac9aef6a863e135474026eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495960
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-04-20 05:24:58 -07:00
Ivan Inozemtsev 264098c85f Revert "[kernel/cfe/etc] Split outline transformation into performOutlineTransformations and performOutlineComponentOperations"
This reverts commit b3d9c8a297.

Reason for revert: b/503506653

Original change's description:
> [kernel/cfe/etc] Split outline transformation into performOutlineTransformations and performOutlineComponentOperations
>
> Currently outline transformations aren't run via the incremental
> compiler which causes problems in
> https://dart-review.googlesource.com/c/sdk/+/491702 which fixes it by
> calling the current transformation in the incremental compiler. This
> calls it twice though (because it's run again in
> `frontend_server/lib/compute_kernel.dart`, but removing it there doesn't
> work because a filtering is done which doesn't apply through the
> incremental compiler.
>
> This CL splits up the outline transformation stage into a call that can
> actually transform the libraries and one that can do the filtering,
> which should fix the issue.
>
> Change-Id: I5ae3477ebfe580dca372ea792924cdfb79979b35
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495700
> Commit-Queue: Jens Johansen <jensj@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

Change-Id: I961a7d2e09f64f4b2e4dc9e45e1f3572f3f2cdeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496260
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-04-17 06:10:08 -07:00
Jens Johansen b3d9c8a297 [kernel/cfe/etc] Split outline transformation into performOutlineTransformations and performOutlineComponentOperations
Currently outline transformations aren't run via the incremental
compiler which causes problems in
https://dart-review.googlesource.com/c/sdk/+/491702 which fixes it by
calling the current transformation in the incremental compiler. This
calls it twice though (because it's run again in
`frontend_server/lib/compute_kernel.dart`, but removing it there doesn't
work because a filtering is done which doesn't apply through the
incremental compiler.

This CL splits up the outline transformation stage into a call that can
actually transform the libraries and one that can do the filtering,
which should fix the issue.

Change-Id: I5ae3477ebfe580dca372ea792924cdfb79979b35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495700
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-15 23:16:03 -07:00
Chloe Stefantsova c82c4632a1 [cfe] Add FunctionNode.thisVariable
In the new variable model `this` is treate as a variable. Similarly to
other variables, it is placed into a variable context, which is
treated as the point of declaration of `this` variable. Since
parameter lists of a `FunctionNode`, such as
`FunctionNode.positionalParameters` and
`FunctionNode.namedParameters`, aren't treated as declarations either,
but rather as a convenient way to access the parameters, a similar
treatment of `this` variable is introduced in this CL, where it
becomes accessible via `FunctionNode.thisVariable`, in addition to
being declared in an appropriate variable context.

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

Change-Id: Ia608fd01661353eb704de225f6b123900b1671b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-04-14 04:18:56 -07:00
Chloe Stefantsova b43c8e8696 [cfe] Remove remaining casting getters from AST nodes
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/492101, where some part
of the casting getters was removed.

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

TEST=ci

Change-Id: I7eefc226ca2edeb10e80d2d110a72acb2b7770f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493681
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-14 02:29:57 -07:00
Lasse R.H. Nielsen 711e50389f Remove var and final from parameters in pkg/.
Doesn't change anything in `front_end/*testcases/primary_constructors/`.
(Would have skipped any other file with `test` in its path and
an explicit language version marker, but there weren't any outside
of those `front_end` directories).

Almost no files used as test input were affected, and none testing the actual syntax changed.
The `.../nnbd/required_2.dart` test case was split into a legacy version retaining the `var`/`final` with a language marker, and a new version without the `var`/`final` cases.

The `pkg/analyzer/` tests, and any other tests that have source code
in strings, are not migrated by this CL.

Tested: No change to behavior. One test split into legacy and new.
Change-Id: I7f5aa4cc98001a9adecacd106c0b3be14f96be1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480542
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2026-04-10 09:09:39 -07:00
Johnni Winther 85991680ac [cfe] Include (super)-initializing-formal modifier in ast-to-text
This adds the initializer-formal and super-initializer-formal modifiers to the ast-to-text output.

These flags are used by backends, so we should expect when these are present.

Triggered by discussion on https://github.com/dart-lang/sdk/issues/62645

TEST=existing

Change-Id: I3eec128c912249bc907931bcf01b52c0ec1eda62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494080
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-04-09 06:22:54 -07:00
Sam Rawlins 82bcae5657 [release] Increase version on main to 3.13
Change-Id: Ice6dfd3b694637da4e20529af9374fece32eda4c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491821
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-08 01:10:34 -07:00
Chloe Stefantsova 86e99cefd5 [cfe] Implement clone methods for the new variable model
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ic255fa48e8fe6611bf00cad8d798cca289b67fa6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492120
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-04-07 04:50:11 -07:00
Chloe Stefantsova aebe572acb [cfe,vm,dart2bytecode] Rename Variable into VariableDeclaration
Part of https://github.com/dart-lang/sdk/issues/61572

TEST=ci

Change-Id: I2c11c354611d48e6b57146fc6f3403597d87c2a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492101
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-04-02 09:33:54 -07:00
kryxen 95c1a0df7f [vm] Apply FFI use-site rewrite in expression evaluation
Run FFI use-site transformation during expression compilation so
evaluate/evaluateInFrame handles FFI use-site APIs (for example,
StructPointer.ref and sizeOf<T>()).

[vm/tests] Add regression for FFI use-site rewrite in compileExpression

R=dacoharkes@google.com, jensj@google.com, leonsenft@google.com

Change-Id: If28f2db1ddbd16931ca441a743041aea496e4f78
Tested: python3 tools/test.py -m release -c dartk -r vm -a arm64 pkg/vm/test/incremental_compiler_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483480
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Auto-Submit: kryxen <kryxen.dev@gmail.com>
Commit-Queue: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
2026-03-26 01:46:34 -07:00
Jens Johansen 4d3d70af23 [kernel] Format kernel
Kernel sdk version was bumped from 3.6 to 3.12 in
https://dart-review.googlesource.com/c/sdk/+/487542 (and to `^3.12.0-0`
in https://dart-review.googlesource.com/c/sdk/+/487880) but the source
was never formatted.

This is, if nothing else, bad for reviews, where editing a file changes
the file in lots of places because of new formatting.

This CL is the result of running

```
out/ReleaseX64/dart-sdk/bin/dart format pkg/kernel/
```

but also updates the formatter version used by a source generator
(`pkg/front_end/tool/visitor_generator.dart`) so things agree.

Change-Id: I66e35d4f1e2d08cecc30fb314546cae78b49e99b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490082
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-03-24 06:00:44 -07:00
Chloe Stefantsova e07e723707 [cfe,dart2bytecode] Apply model-agnostic isThisExpression predicate
In the new model `ThisExpression` is replaced with a `VariableGet`
referring to `ThisVariable`. This CL introduces the model-agnostic
predicate `isThisExpression`, which is applied to replace is-checks on
`ThisExpression`.

The changes in this CL allow to unskip the test `type_ops.dart` in
`bytecode_generator_test.dart`.

This CL is also a follow-up to
https://dart-review.googlesource.com/c/sdk/+/488780/1/pkg/front_end/lib/src/type_inference/inference_visitor_base.dart#3481

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

Change-Id: I9d56ea6a648dc8d299d9a9692b4ffa4459221147
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-23 06:47:10 -07:00
Johnni Winther ee75d1dfab [cfe] Add file offsets for FunctionNode in ast-to-text
This is in preparation for adding missing file offsets.

Change-Id: If122a650a06c9ddf3ae5b73bf75d2f65aea51852
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488482
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-17 06:22:14 -07:00
Chloe Stefantsova 5190320af8 [cfe] Produce synthetic assignments in for-in loops in output form
In the new variable encoding, variables exist either in the internal
form (InternalLocalVariable, InternalSyntheticVariable, etc) or in the
output form, which is passed to the backends. Normally, type inference
is the mechanism that consumes the variables in the internal forma and
produces the variables in the output form. However, some expressions are
produced before type inference (in the BodyBuilder) and will never be
processed by type inference. Synthetic assignments in for-in loops is an
example of such expressions.

This CL modifies the expression generators used by the BodyBuilder, so
that the synthetic assignments are produced directly in the output form,
since they will not be touched by type inference.

This change makes the `loop.dart`, `switch.dart`,
`instance_creation.dart`, `asserts.dart`, `field_initializers.dart`,
`optional_params.dart`, `bootstrapping.dart`, `ffi.dart`, and
`invisible.dart` tests of the bytecode generator to pass, so it can be
removed from the excluded tests when the closure-context-lowering
experiment is enabled.

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

Change-Id: I8d828b7da8e33c6e9fa6bfdda1f201bcdfad9ac4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487840
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-03-16 03:50:37 -07:00
Paul Berry acca99ef86 Fix SDK constraints in analysis_server, front_end, and kernel.
Yesterday I bumped the SDK constraints for these packages to 3.12.0
(see https://dart-review.googlesource.com/c/sdk/+/487521 and
https://dart-review.googlesource.com/c/sdk/+/487542). Today I realized
that this makes a pub solve impossible, since Dart version 3.12.0
hasn't been published yet. That in turn prevents unit tests from being
run in the VSCode IDE.

Changing the SDK constraints to `3.12.0-0` fixes the problem, allowing
the tests to be run under any unreleased version of 3.12.0.

Change-Id: Ia018558dafae9dc958b2b39d19ec1e1d6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-03-13 07:45:41 -07:00
Chloe Stefantsova 67b3b0709f [cfe,vm,dart2bytecode] Rename Variable into BaseVariable, ExpressionVariable into Variable
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/487381/comment/3eb20545_b37553c4/

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

TEST=existing

Change-Id: I15c7438dcec3d412f3050d3d80517d5cff5b515f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487800
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-13 05:42:05 -07:00
Paul Berry cf2cf18751 Bump kernel and front_end to language version 3.12.
Also remove code that is now marked as dead, thanks to sound flow
analysis.

Change-Id: I08c4f5c3a493d561210e8e557cd458fe6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487542
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
2026-03-13 02:08:31 -07:00
Chloe Stefantsova 04e85db143 [dart2bytecode] Visit new variables in Visitors of dart2bytecode
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ie39a97d6444c396570e8d6583cc90a8332ec9757
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487381
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-13 01:42:32 -07:00
Chloe Stefantsova ea1f4d474e [cfe] Introduce InternalSyntheticVariable internal AST node
The new node is generated in for-in loops with synthetic variables.

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

Change-Id: Icaa63097a145d07cdcfe21edc0487a47f90da8dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487060
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-12 01:51:31 -07:00
Daco Harkes a158789f96 [record_use] Constructor invocations via typedefs
Closes: https://github.com/dart-lang/native/issues/2907

TEST=pkg/compiler/test/record_use/record_use_test.dart
TEST=pkg/dart2wasm/test/record_use_test.dart
TEST=pkg/vm/test/transformations/record_use_test.dart

Change-Id: If87b16d314474256ce225d71af771393ebb7d1c7
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/+/485420
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2026-03-09 10:04:45 -07:00
Johnni Winther 988cd0f9b7 [cfe][PrimaryConstructors] Add isRedirecting/SuperInitializer flags to InvalidInitializer
This adds isRedirectingInitializer and isSuperInitializer to the Initializer hierarchy and adds flags to InvalidInitializer to signal when the InvalidInitializer should be taking as a redirecting or super initializer. This allows us to avoid miscatergorizing such declarations when they are erroneous.

Part of #61700

TEST=existing

Change-Id: If0fabbda10b72304999a5380fce74f9e8fa91ca4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486180
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-03-09 03:36:55 -07:00
Sigmund Cherem 3956bd4cd6 [dyn_modules] add support for extension in the dynamic interface
This introduces an `extension` yaml key, similar to `extension_type` to
the dynamic interface.

The validator uses the key to find extensions. Test coverage added
similar to the previous change.

BUG=b/488345908
TEST=pkg/dynamic_modules/test/data and pkg/front_end/testcases/general/dynamic_modules
Change-Id: I4c802663dfee9bf216c0b3dc0f0a0198b8a1fbaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484024
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-04 16:16:38 -08:00
Chloe Stefantsova 1ef944b052 [cfe] Add CatchParameterBuilder
This CL adds `CatchParameterBuilder`, which builds
`CatchVariable`. `BodyBuilderIimpl` and `InferenceVisitorImpl` are
changed accordingly, to produce and handle `CatchParameterBuider`
instead of `FormalParameterBuilder` for the parameters of the catch
clause.

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

Change-Id: I713b55be7d73cdd221736b4facb85b764380761c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484581
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-03-03 04:17:23 -08:00
Alexander Markov 99929813b0 [vm,kernel] Add unique IDs for local functions in kernel AST
The unique IDs are assigned during VM-specific lowering transformation
and recomputed during TFA tree shaking.

The IDs are not assigned when local function AST nodes are created
as it makes certain AST transformations very fragile (e.g. moving
a sub-tree to another parent, cloning a tree to insert into another
member).

The IDs will be used to identify local functions within a member by
the VM and different compilers (dart2bytecode, modular AOT).

TEST=ci

Change-Id: Ifa5dc007322a0137776961d364bbf8565137b318
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-02 06:55:31 -08:00