Commit Graph

2536 Commits

Author SHA1 Message Date
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
Johnni Winther 0f6928c311 [kerne] Add verification of annotation nodes
This adds verification of annotation nodes after constant evaluation should only be ConstantExpression or InvalidExpression.

Prompted by https://github.com/dart-lang/sdk/issues/62096 which crashes from an unexpected annotation expression, like an InvalidExpression.

Change-Id: I91b723f3804694dd317396e2a7a80d50a06b225d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465040
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-12-01 01:38:15 -08:00
Johnni Winther 1a1d7da7a3 [cfe] Use InvalidInitializer
Change-Id: Id4e1df17a14955b58e8db50abefb3ac4bbf1eaf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464686
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-11-27 05:15:04 -08:00
Johnni Winther 4338105c13 [kernel] Make InvalidExpression.message non-nullable
Change-Id: I0b88dfa01a8e2caae8631266310aa3b0a5f5e0bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464685
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 05:15:04 -08:00
Johnni Winther 2352407600 [kernel] Remove unused Target.instantiateNoSuchMethodError
TEST=existing

Change-Id: I38c4f97116f36c4cae079439367afc746415205c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464683
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2025-11-27 01:56:08 -08:00
Johnni Winther 5bc2037cb0 [kernel] Implement InvalidInitializer
This updates the Initializer classes such that InvalidInitializer has a message and will throw at runtime, similar to InvalidExpression. All initializers have positions and only FieldInitializer and SuperInitializer have an isSynthetic field.

TEST=pkg/front_end/testcases/general/invalid_initializer.dart

Change-Id: Ic444bb1dc273b433ac70249240527d115deaa332
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463661
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-27 01:53:23 -08:00
Chloe Stefantsova c94482a3b5 [cfe] Add text serialization for VariableInitialization
This is a step towards better visualisation of the new variable nodes
emitted by the CFE.

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

Change-Id: If39f609627044b97967ed82683bbf49bb02edd5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464182
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-26 03:11:52 -08:00
Jens Johansen 80217511f9 [CFE/kernel] Clear invalidated ClassHierarchySubtypes
Fixes https://github.com/flutter/flutter/issues/178740

Change-Id: Ia7b11ac9785c5bac9a2fec722bd7a4c610171d11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464380
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-11-25 02:01:16 -08:00
Nate Biggs 52be04e90a [dart2wasm][vm] Fix deferred loading with mixin deduplication.
Now moves mixin applications into their own libraries that can be
imported separately from the rest of the code in the originating
library.

Then adds an import to the new library containing the mixin application
to any libraries that use it.

This ensures the import graph is accurate while only making sure it
remains minimal.

TEST=Added case to pkg/vm testcases.

Bug: https://github.com/dart-lang/sdk/issues/43089
Change-Id: I56b6ea1db8261e0d0508c2d7e62d0c13fbe9678b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457260
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-21 10:29:51 -08:00
Alexander Markov d1e27305f7 [kernel] Print 'const' flag of procedures
Change-Id: Iab43421596f649cccd26657d82d08696140ce105
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/463503
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
2025-11-21 03:17:14 -08:00
Chloe Stefantsova a4d6787112 [cfe] Start emititng new variable nodes when the experiment is on
As a part of this CL, the following was changed:

* Instead of `VariableInitialization` implementing `VariableDeclaration`, `VariableDeclaration` now implements `VariableInitialization`.
* `InternalLocalVariable` now implements `LocalVariable`. It delegates most of its members to the variable it wraps around, and the implementations of the `TreeNode` members are throwing.
* Some tests in the bytecode generator under the experimental type started to fail and are skipped.

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

Change-Id: I06b391cc762d5935f528d208ff5e27eccf311a47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-20 01:33:37 -08:00
Chloe Stefantsova cb559f1870 [cfe] Introduce InternalExpressionVariable
`VariableDeclarationImpl` is re-defined in terms of
`InternalExpressionVariable` and `InternalExpressionVariableMixin`.
`InternalLocalVariable` is introduced similarly.

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

Change-Id: I5cb16828687a715cf0f9049338bf461e5ff67f1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/462422
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-18 03:18:33 -08:00
Nicholas Shahan c2c5357a25 [front_end] Add option for expanded invalidation
In this mode when an edit only touches the body of a mixin
(not the public API) libraries that apply the mixin will also
be invalidated.

Add mixin invalidation test.

Issue: https://github.com/dart-lang/sdk/issues/61864
Change-Id: Id4dde67364dcef958ae1e0e0bbf124cec389f5f0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/459343
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-11-14 08:53:51 -08:00
Chloe Stefantsova c97e2554ee [cfe] Make VariableGet and VariableSet abstract interfaces
This change is similar to
https://dart-review.googlesource.com/c/sdk/+/456620 and
https://dart-review.googlesource.com/c/sdk/+/458520 and prepares the
CFE to emit new variable nodes when the experimental flag is on.

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

Change-Id: I78cff188c3a94de337d7114c7496552733b2e208
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461421
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-11-14 03:09:49 -08:00
Chloe Stefantsova 63b34b2e1f [cfe] Implement VariableDeclarations on the new nodes
The nodes that now conform to VariableDeclarations are Variable,
LocalVariable, SyntheticVariable, ThisVariable, FunctionParameter,
PositionalParameter, NamedParameter, and VariableStatement.

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

Change-Id: I6b38d2756662b5bd729d65158621f56791dce829
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-11-10 06:26:34 -08:00
Chloe Stefantsova 756dbcde19 [cfe] Make TypeParameter an abstract interface
The concrete implementation is named `NominalTypeParameter`. The
change is needed as a transition step to the new encoding for
variables in Kernel.

This change is similar to
https://dart-review.googlesource.com/c/sdk/+/456620

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

Change-Id: I9e4107b50a0790008d65a5ee94a4ff06a1b48052
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458520
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-30 09:01:30 -07:00
Chloe Stefantsova dc2a0aae7d [cfe] Always query for ranked superclass info in least upper bound
Previously, the info was inconsistently queried, leading to
nondeterministic behaviors.

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

Change-Id: I5d47d0f29b0e78d2834ae3c5793fd05171cf9156
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/457360
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
2025-10-29 03:10:46 -07:00
Johnni Winther 6d70657fad [kernel] Add RedirectingFactoryInvocation
This adds an internal wrapper expression for redirecting factory invocations. This holds a reference to the original redirecting factory constructor along with the resulting invocation of the generative or factory constructor. The node is removed during constant evaluation and only available to backends through the pre-modular transformations.

TEST=existing

Change-Id: I35c19766117ab2942aefddb4ccebcd2df66babf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454820
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2025-10-28 03:03:44 -07:00
Johnni Winther baf4639de7 [kernel] Add *InternalNodeMixin visitor mixins
This adds mixins for visitors that implement handling of internal nodes. These nodes are replaced during constant evaluation and should there not be handle by backends.

TEST=existing

Change-Id: Iec76af357c11fd54e97a4db82c7aa52e31ba9dd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456680
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-27 15:02:28 -07:00
Chloe Stefantsova 06e54c8c24 [cfe] Make VariableDeclaration an abstract interface
The concrete implementation is named `VariableStatement`. The change
is needed as a transition step to the new encoding for variables in
Kernel.

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

Change-Id: Ib333f28e9998f2e758a18e4ad4b0a3cf4d642013
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456620
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-22 23:11:39 -07:00
Chloe Stefantsova a03be0a31a [cfe] Enable CFE unit testing for closure context lowering
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: Ie44241a3aae78ae766cf06e8da5dc5c167242591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456280
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-10-21 07:04:46 -07:00