Commit Graph

2506 Commits

Author SHA1 Message Date
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
Sam Rawlins be0a084a73 front_end: Remove unused parameters in private functions
Work towards https://github.com/dart-lang/sdk/issues/62767

Each removed parameter is an optional parameter, which never has an
associated argument in any of the function's call sites. The parameters
are used inside the functions though, and so the definition is moved to
be a local variable.

Change-Id: I5627cab797ee371274d697844db810f3d08d20a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483860
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2026-02-27 06:50:02 -08:00
Chloe Stefantsova cf850ff4cc [cfe] Introduce CatchVariable Kernel AST node
`CatchVariable`s are supposed to be used as parameters of the `catch`
block. In the CL they are emitted under an experimental flag.

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

Change-Id: I6a486a63680fb484de7607fdebab8ba9dd975f5b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482783
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-02-24 04:01:49 -08:00
Nate Biggs 3a7b4327e9 [tfa] Ignore missing optional parameters after global optimizations.
TFA currently sets parameter defaults to null when the parameter is unused. The kernel verifier tries to verify that no parameter initializers are null. This causes assertions to fail in dart2wasm when we run the verifier after TFA.

Change-Id: I4e44eca2398b7266f6cb3bbf200009e73e64cbf4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479321
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-02-10 10:15:36 -08:00
Chloe Stefantsova 7b41ba12f8 [cfe] Handle variables captured by initialized of late variables
Field `contexts` is added to `VariableInitialization` nodes, which is
similar to that of `FunctionNode` nodes, indicating the variable
contexts the initializer captures variables from.

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

Change-Id: I8115545ea8a98f6d7827eb833384b29b1799db58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478365
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-02-10 04:07:31 -08:00
Chloe Stefantsova 01b47b5590 [cfe] Create internalThisVariable in Resolver, not BodyBuilder
This is a follow-up to
https://dart-review.googlesource.com/c/sdk/+/475621/comment/3c2355f3_8ca3c92a/

Additionally, `CaptureKind.captured` is renamed to
`CaptureKind.directCaptured` as suggested in
https://dart-review.googlesource.com/c/sdk/+/475820/comment/cdb67c8c_c93196ba/

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

Change-Id: Ib96cb97025d7229d0b87db65149bbb045e5a69c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-02-05 01:53:20 -08:00
Chloe Stefantsova a3eb228d44 [cfe] Add strategy of context allocation based on loop depth
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: If94282dd9e38bfc1807a46831b09ca3ef9d72a52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475820
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-02-02 00:54:29 -08:00
Chloe Stefantsova f474dd9b3e [cfe] Add 'this' variable to closure contexts
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I28c2b9c00d8748162012d184f3b909e8023b2ccf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475621
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-01-26 07:28:03 -08:00
Chloe Stefantsova 5ca6fc646d [cfe,vm] Add 'this' expression to super invocation nodes
This CL adds the field `thisExpression` to the Kernel AST nodes
representing invocations of methods, getters, and setters. The field
is initially populated with `ThisExpression` nodes, and eventually it
will be set to a `VariableGet` of a `ThisVariable` in the new variable
model.

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

TEST=existing

Change-Id: I9d8e96cfe5c392f93d041d8947883fc86189c142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474320
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-01-22 03:08:21 -08:00
Chloe Stefantsova 1fb8ef4ec2 [cfe] Add function parameters to closure contexts
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ic70f9da9fbe22c7e3d59d603563655941e5f5260
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/472200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-01-22 02:14:56 -08:00
Johnni Winther 5d37961bee [cfe][PrimaryConstructors] Mark cyclic constructors as erroneous
This marks constructors whose parameter types have cyclic depencies as erroneous and uses this to avoid type checking invocations. This allows for using the FieldFragmentMixinDeclaration implementation of buildFieldInitializer, which avoid building field initializers twice.

This is done in preparation for support new field initializer scopes for primary constructors.

Change-Id: I302ca6fe2f4de5be0c8b8df1b13570b390c4aa2a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/474720
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-01-22 00:50:32 -08:00
Chloe Stefantsova 47ba2f23a1 [cfe] Use semantic nullability in subtype case of least upper bound
Previously, the declared nullability was used, which doesn't account
for extension types that don't extend Object.

Closes https://github.com/dart-lang/sdk/issues/62242

Change-Id: I2ecf7f8fd53c362468523412b0b59037943e2971
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/473240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-01-15 03:39:31 -08:00
Ivan Inozemtsev 5536cac9c4 [release] Increase version on main to 3.12
Change-Id: I278eb371cd7e8d776a71c1c6f6920b9d0f5598bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460043
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-01-07 00:02:21 -08:00
Johnni Winther 97d965db2a [kernel] Update supportsLateFields reference in documentation
`supportsLateFields` is replaced by `isLateLocalLoweringEnabled` and `isLateFieldLoweringEnabled`. This updates the reference to it in
`Target.supportsLateLoweringSentinel` documentation.

Change-Id: I55f69ea6c5cf5ad590e73e9d224f0a7450872352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470660
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-01-05 02:56:51 -08:00
Ben Konyi 364b36691c Reland "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
This reverts commit c616db31d2.

Reason for revert: Fix landed downstream in Flutter engine: https://github.com/flutter/flutter/pull/180127

Original change's description:
> Revert "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
>
> This reverts commit b5e60be49d.
>
> Reason for revert: broke Flutter web engine tests
>
> Original change's description:
> > [ DDC / CFE ] Add support for allowing imports of unsupported libraries
> >
> > This change adds support for allowing for imports of unsupported
> > platform-specific libraries when the
> > `--include-unsupported-platform-library-stubs` flag is provided to the
> > CFE.
> >
> > This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
> > `TargetFlags`, which `Target`s can use to conditionally return different
> > `DartLibrarySupport` objects with different supported/unsupported
> > library sets.
> >
> > A `checkForUnsupportedDartColonImports` function has been added to
> > `Target` that uses the value of `dartLibrarySupport` to determine if
> > there's any unsupported library imports. This function is called after
> > the various transformation operations provided by the `Target`
> > implementation, meaning the import of an unsupported library specified
> > in `dartLibrarySupport` will now result in a compilation error (this
> > includes `dart:mirrors` imports for VM targets when mirrors are
> > disabled, which was previously handled by the VM itself).
> >
> > Related to https://github.com/dart-lang/sdk/issues/62125
> >
> > TEST=Tests added / modified
> >
> > Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
> > Reviewed-by: Nicholas Shahan <nshahan@google.com>
> > Reviewed-by: Johnni Winther <johnniwinther@google.com>
> > Commit-Queue: Ben Konyi <bkonyi@google.com>
>
> Change-Id: I0b59f00e55a2424f783351abd977eb38409ce01f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469100
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Commit-Queue: Alexander Markov <alexmarkov@google.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

Change-Id: I1ae2eac675432286aebabea3c1f58caf35a27fbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469240
Commit-Queue: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2025-12-19 12:53:22 -08:00
Alexander Markov c616db31d2 Revert "[ DDC / CFE ] Add support for allowing imports of unsupported libraries"
This reverts commit b5e60be49d.

Reason for revert: broke Flutter web engine tests

Original change's description:
> [ DDC / CFE ] Add support for allowing imports of unsupported libraries
>
> This change adds support for allowing for imports of unsupported
> platform-specific libraries when the
> `--include-unsupported-platform-library-stubs` flag is provided to the
> CFE.
>
> This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
> `TargetFlags`, which `Target`s can use to conditionally return different
> `DartLibrarySupport` objects with different supported/unsupported
> library sets.
>
> A `checkForUnsupportedDartColonImports` function has been added to
> `Target` that uses the value of `dartLibrarySupport` to determine if
> there's any unsupported library imports. This function is called after
> the various transformation operations provided by the `Target`
> implementation, meaning the import of an unsupported library specified
> in `dartLibrarySupport` will now result in a compilation error (this
> includes `dart:mirrors` imports for VM targets when mirrors are
> disabled, which was previously handled by the VM itself).
>
> Related to https://github.com/dart-lang/sdk/issues/62125
>
> TEST=Tests added / modified
>
> Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
> Reviewed-by: Nicholas Shahan <nshahan@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Ben Konyi <bkonyi@google.com>

Change-Id: I0b59f00e55a2424f783351abd977eb38409ce01f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469100
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2025-12-18 09:47:11 -08:00
Ben Konyi b5e60be49d [ DDC / CFE ] Add support for allowing imports of unsupported libraries
This change adds support for allowing for imports of unsupported
platform-specific libraries when the
`--include-unsupported-platform-library-stubs` flag is provided to the
CFE.

This flag sets the `includeUnsupportedPlatformLibraryStubs` property in
`TargetFlags`, which `Target`s can use to conditionally return different
`DartLibrarySupport` objects with different supported/unsupported
library sets.

A `checkForUnsupportedDartColonImports` function has been added to
`Target` that uses the value of `dartLibrarySupport` to determine if
there's any unsupported library imports. This function is called after
the various transformation operations provided by the `Target`
implementation, meaning the import of an unsupported library specified
in `dartLibrarySupport` will now result in a compilation error (this
includes `dart:mirrors` imports for VM targets when mirrors are
disabled, which was previously handled by the VM itself).

Related to https://github.com/dart-lang/sdk/issues/62125

TEST=Tests added / modified

Change-Id: Ife819b2e1a6d28f67d80aab6701cd23a1724aa4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465760
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2025-12-17 09:30:38 -08:00
Chloe Stefantsova e1d5dc8c35 [cfe] Assign captured contexts to FunctionNodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Id6293f6300436d252a52e973cba6cd52cda48758
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/468281
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-12-16 05:14:41 -08:00
Chloe Stefantsova 87032377ee [cfe] Use ExpressionVariable in ForInStatement and similar nodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I4f02718dc292b0e18f1fb4858ee31b4c645597a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-11 01:38:24 -08:00
Chloe Stefantsova 95df731257 [cfe] Use VariableInitialization in ForStatement and similar nodes
This change is similar to
https://github.com/dart-lang/sdk/commit/c97e2554ee3b21b0b0146ca41be969dd8531986d,
where ExpressionVariable was used in VariableGet and VariableSet.

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

Change-Id: Id9fa5302adcf8c773cec8478a31948b54c8393b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-08 04:56:51 -08:00
Chloe Stefantsova 6209d8dd0b [cfe] Implement trivial context allocation strategy for local variables
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I7569168e6595e88e2bda25a122f3b238c188b381
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466080
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-12-05 06:59:29 -08:00