Commit Graph

24103 Commits

Author SHA1 Message Date
D.ildo f76fc366de Fix #62883 String buffer clear()
Closes https://github.com/dart-lang/sdk/pull/62931

GitOrigin-RevId: 00a2f30d0906758176575a615d57fdb6c517e23a
Change-Id: I636770b919f3f2358136d05fc373cbd53e88e4ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-25 02:48:45 -07:00
Konstantin Shcheglov 5ef56befcb Variance. Report errors on INOUT and OUT built-in identifiers when Feature.variance is enabled.
Change-Id: I4788439bea71532d2c52b715543f7deaeacdf519
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489982
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-24 13:29:17 -07:00
Martin Kustermann f32057642b [dart2wasm] Run an additional -Os in open world compilation
This reduces e main module size by ~ 0.5-1%

When compiling with deferred loading, we optimize each module
individually with open world assumptions.

Currently we run only one -Os pass which leaves code behind that can be
optimized by another -Os. See e.g. discussion at [0].

The additional -Os pass is much faster than the first, so it doesn't add
meaningful compile-time.

[0] https://github.com/WebAssembly/binaryen/issues/8077

Change-Id: Id8c5e49d97439e28b2f7d9c5a0c206eec0893cad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490101
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-03-24 13:07:26 -07:00
David Morgan f58991b35b Remove augmentation libraries test as it's out of date with the spec.
Change-Id: I6b85558dd3e135612ad45b07aa74e8e85e3321a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490102
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-03-24 08:59:23 -07:00
Lasse R.H. Nielsen cdd8311b14 Make VM run microtasks after an event handler throws.
Tested: Test added for fix.
Change-Id: Ifbefb01ef0caf9de80e44c44e5de4cc51bb129cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-24 06:36:04 -07:00
David Morgan 9ad39ca351 Revert "[test_runner] Support static error test expectations in augmentation libraries."
This reverts commit 261e16e822.

Reason for revert: The feature no longer specifies "augmentations libraries", see 1.22 in the changelog. https://github.com/dart-lang/language/blob/main/working/augmentations/feature-specification.md

Original change's description:
> [test_runner] Support static error test expectations in augmentation libraries.
>
> R=eernst@google.com
>
> Change-Id: I52fd157be6ba561f571170ce393d80820b2744dc
> Bug: https://github.com/dart-lang/sdk/issues/44990
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/356401
> Reviewed-by: Erik Ernst <eernst@google.com>
> Auto-Submit: Morgan :) <davidmorgan@google.com>
> Commit-Queue: Morgan :) <davidmorgan@google.com>

Bug: https://github.com/dart-lang/sdk/issues/44990
Change-Id: Ifbba5d7f7d2720bac3dc638ca00c96246b6fef95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/490100
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Ivan Inozemtsev <iinozemtsev@google.com>
2026-03-24 05:22:10 -07:00
Kallen Tu 7481d41941 [tests] Primary constructors - Add const initializer and body tests.
Tests for the spec change in https://github.com/dart-lang/language/pull/4655.

- An identifier expression denoting a parameter of a constant primary
constructor that occurs in the initializer list of the body part of the
primary constructor, or in an initializing expression of a non-late
instance variable declaration, is potentially constant.
- A compile-time error occurs if a class, mixin class, enum, or
extension type declaration has a constant generative constructor, and a
non-late instance variable declaration in the body of the declaration
has an initializing expression which is not potentially constant.
- A compile-time error also occurs if the body of a declaration contains
a body part for the primary constructor, and it has an initializer list,
and the initializer list contains an expression which is not potentially
constant.
- A compile-time error occurs if the result of substituting actual
arguments of the constructor invocation into one of the above mentioned
initializing expressions or initializer list elements yields an
expression which is not constant.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: I8f9d5d49ab48f6cd07ad005b9483e21ef190f324
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489543
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-03-23 13:59:04 -07:00
Lasse R.H. Nielsen 56505e0575 Stop using Match.group.
The `Match.operator[]` does the same thing and is
generally recommended (and shorter).
(I want to deprecate `group` and `groups`)

Tested: Refactoring.
CoreLibraryReviewExempt: Calling equivalent function.
Change-Id: I4c758968ae622fe16b7322be1b29b05b91e7fcd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489021
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-03-20 09:09:46 -07:00
pq a5bcbf8c1a [deps] bump tools to pull in new unified_analytics
See: https://github.com/dart-lang/tools/issues/2343

This includes a few test updates to play nice w/ changes to `package_config` (https://github.com/dart-lang/tools/pull/2340).



Change-Id: Ia01b9172230a8c3045092d6c3da006e4bfaf3221
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488240
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-03-17 11:53:55 -07:00
Erik Ernst 9d2e96b25f Take steps to support anonymous block bodies
This CL adds support for anonymous block bodies (as in `e.{...}`) by
generalizing the flow analysis to handle begin/end of anonymous block
bodies and treating them similarly to labeled statements (and treating
`return` statements using `handleBreak`). It generalizes `handleBreak`
and the internal make `_StatementToContext` to handle `Node` keys rather
than just `Statement` keys, such that an anonymous block body can be the
context. It adds a `bodyContext` instance variable to
`AnonymousBodyImpl` to be used during flow analysis of anonymous block
bodies. `BodyInferenceContext` gets a new factory constructor in order
to allow an anonymous block body to be the context. Finally,
`ErrorVerifier` is generalized to handle the case where a return
statement is returning from an anonymous block body.

Change-Id: I04bc3c852611dbefb885afce655dc00054709fb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482786
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-03-13 08:54:16 -07:00
Martin Kustermann 2e2f8ae7b3 [dart2wasm] Make normal dynamic calls avoid wasm array creations
Currently a dynamic call will call a helper which will create
3 array objects (for type, positional and named arguments).

It will then pass those wasm arrays to type checker methods.
Those will then get values out of the array, type check and call
the target.

We change this now such that in the normal case (**) we avoid
the array creations. Instead we make a dynamic forwarder function
per target and call shape.

We also outline the array creation when creating `Invocation`
objects. So for simple caller shapes - such as `clone()` the
creation of an `Invocation` object is a call without arguments
instead of various array creations.

Issue https://github.com/dart-lang/sdk/issues/62640

(**) If the dynamic call could be call-via-field we still create
those arrays, as we use them for closure type checking.

Change-Id: Ia8f3f3cd95f650bd8706a15ed68a43db4de80a6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487020
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-03-12 02:17:07 -07:00
Kallen Tu 39870102e6 [tests] Primary constructors - More cases for empty body test.
From Lasse's comment in
https://dart-review.googlesource.com/c/sdk/+/486525. Added many more
combinations of extends, implements and mixin applications to
`empty_body_test.dart`.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: Ie26c7661d6505d21c2f457b285f1ef1b88b8e6ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486863
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-03-11 16:07:00 -07:00
Alexander Aprelev 46cf07fe35 [vm/shared] Ensure scratch register is requested as temp for LoadStaticFieldInstr.
TEST=tests/ffi/many_listener_callbacks_test/5 on vm-ffi-qemu-linux-release-arm

Change-Id: I6a60220bce6dbc760e3a027b1b023c59dff36ba7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/487200
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-03-11 13:11:32 -07:00
Kallen Tu d87e8f866c [tests] Add test for explicit class body on mixin applications.
Adding in an extra test just to make sure this isn't
possible. Don't know if we already have a test for this,
but I couldn't find anything.

Change-Id: Id2ce089e070cc139389e805f1b8b7f987a438bfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486525
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-03-10 14:58:45 -07:00
Johnni Winther a6bc2c3608 [cfe][PrimaryConstructors] Use MemberLookupResult for redirecting initializers
This uses MemberLookupResult instead of Builder as the result for BodyBuilderContext.lookupConstructor. This allows for a more precise handling of error cases and avoids reporting cascading error in case of duplicate constructors.

Change-Id: I465747883af594870cb0663e80a188e6dd1b552b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486202
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-03-10 02:55:53 -07:00
Kallen Tu dde4b2475d [tests] Variance - out and inout are built-in identifiers.
Updating language tests to mark `inout` and `out` as built-in identifiers. They should produce a compile-time error if used as a type name.

Bug: https://github.com/dart-lang/language/issues/524

Change-Id: Ibdefb1090ecdd64c2bee4dcb7cc5ec8708455fcf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486341
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-03-09 13:19:16 -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
Konstantin Shcheglov 7b26f656eb DeCo. Evaluate field declaration initializers with primary constructor formal parameters, check primary constructor body initializers.
Change-Id: I6ef5266abbb7cccf3f8dc3289b26111b9fef906d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-03-06 10:20:49 -08:00
Sergey G. Grekhov d21c373170 [co19] Roll co19 to d22c40f238af3f2fdc30335a3f45efcee9172835
2026-03-05 sgrekhov22@gmail.com dart-lang/co19#3182. Add/update tests for eliminated errors (dart-lang/co19#3645)
2026-03-05 sgrekhov22@gmail.com dart-lang/co19#3182. Add tests for static abstract declarations. Part 1. (dart-lang/co19#3638)
2026-03-04 sgrekhov22@gmail.com Fixes dart-lang/co19#3635. Fix potentially constant expressions in enum (dart-lang/co19#3639)
2026-03-04 sgrekhov22@gmail.com dart-lang/co19#3315. Add more test cases for `<classNameMaybePrimary>` without `<primaryConstructor>` (dart-lang/co19#3631)
2026-03-04 sgrekhov22@gmail.com dart-lang/co19#3182. Update text in assertions (dart-lang/co19#3644)
2026-03-04 sgrekhov22@gmail.com dart-lang/co19#3182. Update existing tests for const and final initialization (dart-lang/co19#3643)
2026-03-03 sgrekhov22@gmail.com dart-lang/co19#3182. Add more tests for primary constructors (dart-lang/co19#3617)
2026-03-02 sgrekhov22@gmail.com Fixes dart-lang/co19#3632. Update positions of expected errors (dart-lang/co19#3633)
2026-03-02 sgrekhov22@gmail.com dart-lang/co19#3182. Add missing `const` to enum constructors augmentations (dart-lang/co19#3630)
2026-03-02 sgrekhov22@gmail.com Fixes dart-lang/co19#3637. Update expected errors locations in grammar_A03_t02.dart (dart-lang/co19#3640)
2026-03-02 sgrekhov22@gmail.com dart-lang/co19#3182. Update assertions text (dart-lang/co19#3629)
2026-03-02 sgrekhov22@gmail.com dart-lang/co19#3182.Add tests for external js interop variables, getters and setters (dart-lang/co19#3621)
2026-02-23 sgrekhov22@gmail.com Fixes dart-lang/co19#3626. Call method `factory()` in `main` (dart-lang/co19#3628)

R=athom@google.com, eernst@google.com

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try
Change-Id: Ia6206a39635cd3f97f0cf6e83a8bce4441c94497
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486120
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-03-06 05:52:21 -08:00
Johnni Winther 44b6fe89e7 [PrimaryConstructors] Update test expectations
This updates the test expectations for the CFE.

Part of #61700

Change-Id: Iad25b48ab10809c95e2489821b318c6435f96ec0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485800
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-03-06 00:16:34 -08:00
Kallen Tu 86232e2c3a [tests] Primary constructors - Allow ; bodies on any membered declarations.
Updating some primary constructor tests in light of issue 4645 that allows `;` on any membered declarations.

Bug: https://github.com/dart-lang/language/issues/4645, https://github.com/dart-lang/sdk/issues/61687
Change-Id: I390ccd1eb1c84d55ee599d4d94ab199bb4920880
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485585
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-03-05 11:12:02 -08:00
Martin Kustermann 2c8f4300d0 [dart2wasm] Fix @pragma('wasm:initialize-at-startup') in deferred loading scenario
The module owning the storage for the static field has to emit the
initialization code in it's start function.

Change-Id: I9089e99d6e12ea275343cebe3e456658a7c7a540
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485480
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-03-05 11:10:13 -08:00
Alexander Markov 8c7ef075a9 [tests] Skip standalone/file_system_watcher_isolate_exit_leak_test on sanitizer bots
Memory allocation and access by sanitizers affects RSS in unpredictable
way, which confuses RSS measurements in this test.

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

Change-Id: Ice38677d084e93c1b5deda20d68414a119c678db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/485840
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2026-03-05 08:11:22 -08:00
Kallen Tu f7f8ab8986 [tests] Primary constructors - Tests on assignment, naming conflicts, and more.
Language tests for the following:
- A compile-time error occurs if an assignment to a primary parameter
occurs in the initializer list of the body part of a primary
constructor.
- A compile-time error occurs if an instance variable declaration has an
initializing expression, and it is also initialized by an element in the
initializer list of the body part, or by an initializing formal of the
primary constructor.
- The modifier `final` on a parameter in a declaring constructor
specifies that the instance variable declaration which is induced by
this declaring constructor parameter is `final`.
- A compile-time error occurs if a class, enum, or extension type has a
primary constructor whose name is also the name of a constructor
declared in the body.
- Extension types are allowed to have non-redirecting generative
constructors, implicitly or explicitly initializing the representation
variable.
- A compile-time error occurs if a class, mixin class, enum, or
extension type declares a primary constructor whose name is `C.n`, and
the body declares a static member whose basename is `n`.
- Consider a factory constructor declaration of the form `factory C(...`
optionally starting with the modifier `const`. Assume that `C` is the
name of the enclosing class, mixin class, enum, or extension type. In
this situation, the declaration declares a constructor whose name is
`C`. The rule which is being tested here is also applicable when the
declaration has some of the keywords external and augment, but we don't
test those kinds of constructors here.
- It is an error to have multiple primary constructor bodies.
- Tests for type inference of declaring parameters in primary
constructors, including override inference and inference from default
values.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: If804c99c317ab53643420e00d6dc266720bca2f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483626
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-03-03 18:47:32 -08:00
Nate Biggs c3b28c2da4 [dart2wasm] Add test for stack traces originating in JS.
Ensure we don't remove any frames from these like we do for Dart stack
traces.

Change-Id: I32c3a53bc229873a05e35767f7fa27c2ec4643e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483846
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Auto-Submit: Nate Biggs <natebiggs@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-03-03 13:52:30 -08:00
Nate Biggs 3c0573bcd1 [dart2wasm] Update main invocation patching to avoid leaking types into the program.
Dart2wasm started using RTA to significantly speed up compilation.
However, a side effect of this is less exact type info during TFA.

In _invokeMain we conditionally use some js-interop logic when a
program's main takes arguments. On the web, most programs don't expect
any arguments so this is usually dead code. However, RTA sees
_invokeInternal is live and blindly treats all reachable classes as live
including the unused interop helper types in the other branches.

This code refactors the patching logic to make sure only the relevant
entry point is considered live.

This change uncovered a different bug that was suppressed by these
implicitly instantiated types. Dart2wasm was not marking some internally
instantiated classes as allocated in the function logic so entries in
the dispatch table were empty for those types. Instead any time we
generate the code for a constructor (which may not be reached via a
ConstructorInvocation like we were assuming before), we record the class
as allocated.

Change-Id: I556d3733c00b4a3e3455fa1ee2c90206d54c81f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/484540
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-03-03 09:01:46 -08:00
Shanu Kumawat dba9cb988c [analyzer/ffi] Check @Native on extension members
Validate @Native annotations on extension and extension type instance
members by modeling the receiver as the first Dart parameter when
checking the full function type against the FFI signature.

This aligns analyzer diagnostics with CFE behavior for extension-like
members (issue #60250), while preserving the pointer-receiver
restriction diagnostic behavior introduced by #62716.

Fixes: https://github.com/dart-lang/sdk/issues/60250

TEST=tests/ffi/static_checks/regress_60250_test.dart
TEST=tests/ffi/static_checks/regress_62716_test.dart
TEST=pkg/analyzer/test/src/diagnostics/ffi_native_test.dart

R=davidmorgan@google.com

Change-Id: I688f338f47aa1f6670afce2cb4d4d4f88e3816ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482160
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Auto-Submit: Shanu Kumawat <shanu.kumawat.dev@gmail.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-03-03 01:03:36 -08:00
Alexander Aprelev f3bc347448 [core/shared] Allow for BigInt to work in isolategroup-bound callbacks.
Introduce runtime checks for BigInt to allow it being used as deeply immutable class.

TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Bug: https://github.com/dart-lang/sdk/issues/62601
Change-Id: I343862bdf5603be571d3bf937261dd61aca9ca0e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/477040
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-03-02 13:52:34 -08:00
Colton Grubbs 6c587065a2 [io/http] Fix race condition where RawSecureSocket dispatches read events after shutdown
Closes https://github.com/dart-lang/sdk/pull/62520

GitOrigin-RevId: d2bdfac991eb2427530a52b6f3cc26f5577fdf2d
Change-Id: Ib1a6620af1710d682ea46620517a3b1363eb2bd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475941
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-03-02 01:47:04 -08:00
Nate Biggs 0f3c75d1eb [js_interop] Add jsIdentical function that implements === on JS values backing Dart values.
dart2js and DDC implement `identical` using JS `===`. This means for
interop values the objects will be compared using JS strict equality
semantics. For Strings in particular this means value equality rather
than reference equality.

In wasm we use equality on the struct reference wrapping the JS value.
This leads to differing semantics between JS and wasm when using
identical on these JS wrapped values.

`jsIdentical` provides a way to have consistent semantics between JS and
wasm.

Change-Id: I207fbbb294254798372924a55cdb2691094a5461
CoreLibraryReviewExempt: Just updating web-related code.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483440
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-02-27 16:27:06 -08:00
Konstantin Shcheglov d53c3e01ed DeCo. Evaluate field initializers as evaluate const constructor.
As a preparation for evaluating instance field initializers in classes
with primary constructors, where you can reference formal parameters of
these primary constructors.

Change-Id: I8c1276ec9ae7b2f5950a1abefb7cb8492a736dfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483843
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-27 10:54:33 -08:00
Alexander Aprelev e9229a0585 [core/shared] Allow http ContentType to work in isolategroup-bound callbacks.
TEST=run_isolate_group_run_test

Bug: https://github.com/dart-lang/sdk/issues/61030
Change-Id: I2262f22f0bca4ef35add27c54cc1a84b3f5bbd76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478221
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-02-27 07:43:14 -08:00
Nate Biggs 72d87adf69 [dart2wasm] Make stacktraces more consistent
Add `never-inline` pragma to all methods in the "StackTrace.current"
call hierarchy. If dart2wasm or wasm-opt inline any of these the number
of frames to remove is inconsistent.

Also only remove frames when the stack trace is from "current", not when
it's from the other JavaScriptStackTrace constructor.

Fixes issue raised in: https://dart-review.googlesource.com/c/sdk/+/479640/comments/7be8f913_489aa935

Change-Id: Id15252cc210bb79f28acad4bc78ce9ee8ff69ac7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483624
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-02-26 11:54:34 -08:00
Jessy Yameogo 023d12877a [corelib] added entry to status file for group_modifier_test
Safari currently lacks support for new RegExp group modifiers, causing `group_modifier_test.dart` to fail on `dart2js-mac-safari` and `ddc-mac-safari`. This change explicitly marks the test to expect a `RuntimeError` on these configurations rather than skipping it entirely.

Fixes https://github.com/dart-lang/sdk/issues/62753
Change-Id: Iff2007a7b50ee2a4a29f6e7aecbc1930ccdf8967
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483380
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Jessy Yameogo <yjessy@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-02-24 17:48:27 -08:00
Srujan Gaddam 0615d3a467 [dart:js_interop] Make isA<JSExportedDartFunction>() check that it's a wrapped function
Closes https://github.com/dart-lang/sdk/issues/62573

isA<JSExportedDartFunction>() used to just check if the object
was a function, leading to a possible runtime error if `toDart`
is called. Fixes that by introducing some helpers and moving
around some functions in the JS compilers to other internal
libraries (public members can't be added to
js_allow_interop_patch.dart). Also fixes a minor issue in dart2js
where `allowInterop`ed functions could successfully invoke
`JSExportedDartFunction.toDart`.

CoreLibraryReviewExempt: Documentation change.
Change-Id: I5a9d7c31d3143eb3fb6ebd3273a4bf06ca329479
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482967
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2026-02-24 10:40:43 -08:00
Daco Harkes 8852aa5c19 [analyzer/ffi] Fix analyzer crash
TEST=tests/ffi/static_checks/regress_62716_test.dart

Fixes: https://github.com/dart-lang/sdk/issues/62716
Change-Id: I8abc006cd1e7274089ea618c970aacd0bc2267e4
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,analyzer-win-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,front-end-nnbd-mac-release-x64-try,front-end-nnbd-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/483241
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2026-02-24 05:01:40 -08:00
Ömer Ağacan 590b656877 [dart2wasm] Update JS exception catching
This updates JS exception catching as discussed in #55481:

- Only catch JS exceptions when the exception type is `dynamic`,
  `Object`, or an extension of `JSValue`. (nullable or not)

  (Previously we also caught JS exceptions when the type is `Error`.)

- When the JS value caught in Wasm is `null` or `undefined`, box it as a
  non-interop class. For compatibility with dart2js, this class is
  copied from dart2js and has the same `toString` as the dart2js class.

- In other cases: box the JS values as `JSValue`. This means the value
  can be passed as any of the interop types, and can be passed back to
  JS without manual jsification.

Fixes #55481.

Issue: https://github.com/dart-lang/sdk/issues/55481
Change-Id: I23e73074729f740b90df2ca8b3c713fb39966556
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479640
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2026-02-24 01:43:10 -08:00
Konstantin Shcheglov 51cdf271de DeCo. Report diag.duplicateDefinition for defining formal parameters with name '_'.
Change-Id: I6c8d9cbacb78efb17fd5b8603263deb3d65e6335
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482660
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-02-23 10:23:15 -08:00
Ryan Macnak e443b89f23 [vm] Update Irregexp to V8 commit 254cc758346f10be2a7e22e55d90d4defe9cad74.
Includes support for modifier spans and duplicate named capture groups.

Drops the flow graph implementation to ease maintenance.

TEST=corelib/regexp
Bug: https://github.com/dart-lang/sdk/issues/56573
Bug: https://github.com/dart-lang/sdk/issues/61337
Bug: https://github.com/dart-lang/sdk/issues/62349
Bug: https://github.com/dart-lang/sdk/issues/62708
Change-Id: I05640ba945a4fa5476e7ad463738f4f39d842c14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480121
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-23 09:54:47 -08:00
Alexander Markov 39c5a61f89 [vm] Check covariance of type parameters of a forwarding stub instead of its target
A forwarding stub can have a covariant type parameter while the same
type parameter in its forwarding stub target is non-covariant.

We should still check bounds of such type parameters
(the bound to check is taken from the forwarding stub target).

TEST=tests/language/regress/regress62664_test.dart
Fixes https://github.com/dart-lang/sdk/issues/62664

Change-Id: I86eeb9f8a537c22fb473388f9b17f55084af6366
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-02-23 07:27:56 -08:00
Daco Harkes 86880a4cab [cfe/ffi] Don't transform methods if wrong number of arguments
TEST=tests/ffi/static_checks/regress_62693_test.dart

Closes: https://github.com/dart-lang/sdk/issues/62693
Change-Id: Ifa9228568a4b01f162df727f80cbb923d148d043
Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,analyzer-mac-release-try,analyzer-win-release-try,front-end-linux-release-x64-try,front-end-nnbd-linux-release-x64-try,front-end-nnbd-mac-release-x64-try,front-end-nnbd-win-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482760
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2026-02-23 03:50:41 -08:00
Paul Berry d0278ea7b8 [flow analysis] Test post increment/decrement demotion.
Adds a language test and a flow analysis unit test to cover a flow
analysis behavior of post-increment and post-decrement operators that
wasn't previously covered.

The tests verify that the expressions `x++` and `x--` demote `x` in
the same way that `x = x + 1` and `x = x - 1` would. This demotion is
only user-visible if the type of `x` is a user-defined type.

In the process of writing these tests, I noticed that the "mini-AST"
implementation of post-increment (which is used solely for flow
analysis unit testing) was not correct; it presumed that the type read
from the target, the type written to it, and the type of the whole
expression were all the same. This is not correct; the type written to
the target is determined by the return type of the `+` operator. I've
fixed this as part of this CL so that the unit test properly exercises
flow analysis.

I will follow this up with some refactoring of how flow analysis
handles post increment/decrement operations. Landing the test first
allows us to be confident that the refactor won't change the tested
behavior.

Change-Id: I6a6a6964417b48db0c1681c06d7418bd79e96357
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482342
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-21 10:59:44 -08:00
Kallen Tu 6005ca0cf7 [tests] Primary constructors - Wildcards, assignment, initializing formals.
Tests the following:
- A compile-time error occurs if an assignment to a primary parameter
occurs in the initializing expression of a non-late instance variable.
- A compile-time error occurs if a declaration has a primary constructor
with an initializing formal and no instance variable of the same name.
- Declaring parameters named `_` cannot be declared multiple times in a primary constructor.
- Wildcard variables cannot be referenced in the initializing
expressions of non-late instance variables or in the initializer list of
the body part of the primary constructor.
- Declaring parameters named `_` are allowed. Accessing `_` is valid in
the body part of a primary constructor if there's an instance variable
with the name `_`.

Bug: https://github.com/dart-lang/language/issues/4634, https://github.com/dart-lang/sdk/issues/61687
Change-Id: Id2cb98bd78e31292894610b595174fa682bdc1ae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481321
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-02-20 16:03:44 -08:00
Nate Biggs 1fc8f6e988 [dart2wasm] Fix missing cases in deferred loading fine grained dependency calculation.
- The dependencies of a class should also include the initializers for its fields. These are used to initialize the class object. And they are not represented in the constructor Initializers list.
- Super gets/sets/invocations should all visit their children as well. These aren't leaf nodes.

Change-Id: I552bc87cf1bbc35b11b0dd7bcbd167b2fa5bcbe7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481680
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-02-20 11:53:17 -08:00
Kallen Tu 6b79420b4c [tests] Primary constructors - Var usage in function-typed initializing formals, super, and typedefs.
Added a few tests for typedefs, function-typed initializing formals, and function-typed super parameters, and using `var` in a parameter of a function type.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: Icb234b5ee14c239219fd6b4503ae8848731fffcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482082
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-02-20 09:29:36 -08:00
Kallen Tu 14ae04c79b [tests] Primary constructors - Late and external tests.
Removing `late_external_test` since it's not testing anything new to primary constructors and the d2js/ddc errors already have test coverage.

Separating the late and external error tests (for the keyword in the header) so that we can make sure both errors are being reported.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: I6dff4c47ad07a7b0149316a6831793db162f392e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482040
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-02-20 09:26:42 -08:00
Erik Ernst c7e6c98877 Implement analyzer support for => anonymous methods
This CL adds implementation of the static analysis of anonymous methods
whose body is of the form `=> e`. Block bodies are still rejected by a
`UnimplementedError` exception.

Flow analysis is rudimentary, but this might be sufficiuent for the
particular kind of anonymous methods which are covered by this CL. In
particular, it does not cause assigned local variables to be marked as
non-promotable in enclosing scopes, and it does allow local variables
promoted in the anonymous method body to preserve their promotions after
the anonymous method invocation.

Note that the change in `_resolveReceiver` is needed because the old code relied on looking up the syntactically enclosing class or extension in order to determine the type of `this`, but that is incorrect when `this` may be the type of the receiver of an enclosing anonymous method.

Change-Id: I3d2bd6d104015a6e310e9ce061c7b4109002a1b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-02-20 06:58:36 -08:00
Srujan Gaddam 7d46e28cdf Skip isa_test on dart2js with CSP
https://dart-review.googlesource.com/c/sdk/+/478241 renamed
functional_test.dart to isa_test.dart. The CSP bot doesn't run
on presubmits, so this broke the bot in postsubmits.

Change-Id: I90486e706c2860d1351f79aa5d3fe8b710be97ee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482063
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2026-02-19 15:20:59 -08:00
Srujan Gaddam 9f367b1709 [dart:js_interop] Expand isA to Object?
Fixes https://github.com/dart-lang/sdk/issues/56905

Instead of just supporting isJSAny and isJSObject, we
can support isA for all objects. Depending on the static
type, we include an intrinsic _isJSAny function first in
the transformation. For fast paths for JSObjects, we also
now call an intrinsic function which has the added benefit
of now correctly returning true for objects with no prototype.

The intrinsic functions in dart2wasm need to be careful to
not treat ExternalDartReferences as JS values, so JSValue
is amended to include a field that determines if the value
is a Dart value (and caches it if not set already). JSValue
constructions are updated to pass false for this field if
we know for sure this value isn't an externalized Dart value.

CoreLibraryReviewExempt: Backend-specific function changes.
Change-Id: Ib2a6e74b4130632791375fcda9a5b85198ad64af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478241
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-02-19 14:10:32 -08:00
Nate Biggs a484bb3973 [dart2wasm] Use constants to represent dummy values.
Today "dummy values" are generated per-module to stand in for things
like default parameter sentinels (where a given selector has multiple
default values for an optional parameter).

However, these values can end up crossing between modules. The logic is
set up to use ref_eq to check if an argument is one of these dummy
values. However, if one of these dummy values crosses between modules,
the passed value vs the ref_eq checked value will be different. Since
each module has its own canonical dummy value per type.

This new layout simplifies our handling of these dummy values by
treating them as Constants so that our normal module canonicalization
logic applies to them. We already have plenty of logic to canonicalize
constants across modules. This avoids the need for custom handling of
these dummy value globals.

Change-Id: Ia9c79923c788d7712b16705193ffbf3142141b5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-02-19 12:48:49 -08:00