Commit Graph

24166 Commits

Author SHA1 Message Date
Martin Kustermann 84704290ab [vm] Change various external FFI declarations from Object to Object?
The C side can return any object, including `null`, we should therefore
change those declarations to return top type / `Object?`.

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

TEST=https://dartbug.com/63411

CoreLibraryReviewExempt: Internal only changes
Change-Id: I6478e39113fba5d422059de62b88fe738ddbfc05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/504920
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-20 02:28:18 -07:00
Simon Binder 58f9d88fb2 [dart2wasm, standalone] Migrate String
This migrates the `String` implementation from using JS interop to
explicit host imports for the standalone target.

This moves a few helper methods shared between the JS and standalone
targets to `dart:_string_helper`. This also moves the embedder regexp
implementation to `dart:_string` to be able to access internals in some
string methods (similar to how the JS implementation special-cases
`JSSyntaxRegExp`).

This removes the final real use of JS-interop in the standalone target.
So, we can:

 - Remove internal JS helper libraries from the target.
 - Skip JS-interop transformations in the compiler.
 - Stop emitting a helper module and support script.

Because `js_interop` is imported in `dart:_wasm`, we can't remove the
library entirely. This replaces it with a stub to avoid compilation
errors, a proper removal is tracked in dartbug.com/63166.

Change-Id: Ide495c210c3a272438deebf8fe4f3f44ba314ffa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501960
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-05-20 00:22:27 -07:00
Ryan Macnak d36adbacaf [vm] Remove the VM isolate.
The former contents of the VM isolate are now included into each isolate group. This makes each isolate group's heap independent, and in particular allows each heap to be allocated to a separate pointer cage (not done in this CL).

The duplicated stubs that allowed PC relative calls are removed, since the originals can now be the target of PC relative calls.

The bootstrapping needing to load an AppJIT or AppAOT snapshot is reduced to allocating the oddballs. The code is entirely dropped in the AOT runtime, but the JIT runtime still has it to allow for flags to affect the compilation of the stub code. Further refactoring might be able to remove this for the JIT runtime too, with only gen_snapshot knowing how to bootstrap.

Class serialization no longer distinguishes predefined classes.

The page containing null is marked as never-evacuate. null, false and true must not move because the compiler relies on their low bits having certain patterns for some optimizations. (Previously, the entire VM isolate heap never moved.)

Compaction is disabled for IA32. Due to register pressure, some stub calls must not use a scratch register and embed the address of Code.

The page containing the call-through-safepoint stub is frozen when running with --write-protect-code and the stub is created at runtime (instead of loaded from an AppJIT or AppAOT snapshot). This stub must remain executable even during a safepoint, as a foreign call might during return during a safepoint and only block after the stub directs it to the runtime.

The snapshot symbols are renamed to kDartSnapshotData and kDartSnapshotText. There is no need to distinguish the VM isolate's snapshot, and snaphots are per isolate group not per isolate. Aliases with the old names are added to ease migration.

Some global flags that were automatically set based on the VM isolate's snapshot are now isolate group flags and automatically set by the isolate group's snapshot.

TEST=ci
Change-Id: Iee82016057d609112e9b021d178fc3d4d18b5044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500621
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
SLSA-Policy-Verified: SLSA Policy Verification Service <devtools-gerritcodereview-exitgate@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-05-18 11:35:03 -07:00
Kallen Tu 2edcad4892 [tests] Primary constructors: Format and generate errors for all tests.
Cleaned up and formatted the tests, regenerated some errors where they were "unspecified", and removed the experiment flag enabling in each test.

Bug: https://github.com/dart-lang/sdk/issues/61687
Change-Id: Ic5b652af660cbc4f71731b1547c7a58c7726faca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503500
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-05-18 10:00:37 -07:00
Konstantin Shcheglov 5ed538a532 Bug fix: implement missing diagnostic implementsSuperClassConstraint.
It is disabled when augmentations feature is enabled.

This is not a breaking change, because CFE did report this error.

The relevant reason is indirect, not a single sentence saying “on A
implements A is forbidden”.

Spec chain:

1. In dartLangSpec.tex:6019, a mixin declaration is modeled as:

`mixin N<T...> on T1, ..., Tn implements I1, ..., Ik { ... }`

2. In dartLangSpec.tex:6065, the mixin interface M_I is defined as if
by:

`abstract class N<T...> implements T1, ..., Tn, I1, ..., Ik { ... }`

and dartLangSpec.tex:6078 says it is a compile-time error for the mixin
if that synthetic class declaration would be a compile-time error.

3. In dartLangSpec.tex:5189, class superinterfaces say:

It is a compile-time error if two elements in the type list of the
IMPLEMENTS clause of a class C specifies the same type T.

So:

`mixin M on A implements A {}`

is checked like:

`abstract class M implements A, A {}`

which violates the duplicate implements type rule.

Change-Id: I29e5fa17c47d111346ef6a6e321ab5dbab985ad1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503501
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-18 07:55:50 -07:00
peeefour 1d80afe498 [vm/io] Range check Socket_SendMessage arguments
Closes https://github.com/dart-lang/sdk/pull/63365

GitOrigin-RevId: 344604dd1a17b73c6665026e7e75693fe0fa7ca7
Change-Id: I8f51d5735a56564f2181bcd1206c9cfdff80f077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502960
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-13 03:40:04 -07:00
Erik Ernst 96a4dd4c19 Modify property promotion: only this
https://dart-review.googlesource.com/c/sdk/+/498840 added support for
promotion of properties (private, final instance variables with a name
which isn't used much for other purposes) in the context of anonymous
methods.

This CL reduces the set of situations where this feature is enabled such
that only `this` will allow property promotions to be carried in (such
that `this._x` is promoted in `v.=> this._x` when `v` is such that
`v._x` has been promoted before the anonymous method occurs). It also
generalizes the mechanism such that property promotions are carried out
(so we can do `if (v.=> _x is int) v._x.isEven;`).

Tests has been adjusted accordingly.

Change-Id: Ibe70713d3d9c89a6d95f9c3dd28df8f147cb518d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502660
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-05-13 00:08:24 -07:00
Nate Biggs 63d042fe0d [dart2wasm] Fix dynamic dispatch table population for multiple modules.
When deferred loading was enabled the dynamic dispatch class ID table
was incorrectly assigning class IDs to the wrong module. If a contiguous
target segment included classes/targets from different modules, all of
them were getting assigned to the module of the first class/target in
that segment.

This was causing spurious NSM exceptions as the necessary rows in the
table might not be populated for a dynamic call if the module the
segment was assigned to wasn't loaded yet.

To fix this we end the segment if the next target does not belong to the
same module as the active segment.

The new test fails with an NSM exception prior to this fix.

Change-Id: I07bc4fdb5a8bff1bfad5fe17f45c8076a965a775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502860
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-12 12:54:38 -07:00
Modestas Valauskas 754239b077 [core] Add trailingZeroBitCount and oneBitCount to int
Adds two new getters to int for bit-counting: trailingZeroBitCount
(ctz) and oneBitCount (popcount). On native platforms they operate
on the full 64-bit two's-complement representation; on the web they
operate on the least-significant 32 bits.

Implementations:
- VM: unified C++ natives Integer_trailingZeroBitCount /
  Integer_oneBitCount on _IntegerImplementation, using
  Utils::CountTrailingZeros64 and Utils::CountOneBits64. The receiver
  may be _Smi or _Mint at runtime.
- dart2js / DDC: clz32-based ctz and a SWAR popcount.
- dart2wasm: inlined i64.ctz and i64.popcnt intrinsics.

leadingZeroBitCount (clz) is intentionally excluded from this CL: its
result depends on the platform integer width (e.g. 1.leadingZeroBitCount
is 31 on web, 63 on native), and the same value can be derived from
the existing bitLength getter when needed.

Asm intrinsification on native architectures is intentionally left for
a separate follow-up CL.

Work towards https://github.com/dart-lang/sdk/issues/6486 (this CL
covers popcount and ctz from the bit-twiddling list; clz, rotate,
reverse, and others remain).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Bug: https://github.com/dart-lang/sdk/issues/52673
Bug: https://github.com/dart-lang/sdk/issues/38346
TEST=tests/corelib/int_bit_count_test

Change-Id: I8a5cdb5c91360478f47bbd6b9c84ca1c477aa8c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498041
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-05-12 05:49:31 -07:00
Alvin 7bc22cf877 [vm/io] Range check SynchronousSocket_WriteList arguments
Closes https://github.com/dart-lang/sdk/pull/63358

GitOrigin-RevId: 1a5eb0d7e11fca131a721cd0535954f96ac1dfaf
Change-Id: I670ebdd4fadef383872a9d719efa22d6479b812d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502441
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-12 00:32:52 -07:00
Nate Biggs 0af31e37bb [dart2wasm] Fix context collection emptiness false positive.
In some cases, closure contexts were being left out of the parent chain
of their children because they were empty at the time the child closure
was created. If a usage appeared later in the visit of the parent, the
context would no longer be empty but the child would already be created
without a parent.

This was easiest to recreate in sync* function because unlike async, it
doesn't introduce hoisted helper variables (these immediately mark the
parent as non-empty).

In the attached bug the repro only happens with named parameters because
TFA transforms the named parameter into a Let that introduces a variable
before the closure with the usage in the let body after the closure. The
new test explicitly introduces the same pattern of a variable declared
before the closure and used after it.

The fix here is to not eagerly check for emptiness of the parents.
Instead we post-process the Contexts and relink the parent tree skipping
any empty nodes.

Bug: https://github.com/dart-lang/sdk/issues/63264
Change-Id: I2f75506b9fa879544b1a606d8f157fbd44ba8ce2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500680
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-07 09:21:19 -07:00
Erik Ernst 1b75e2701c Support promotion of instance variables with anonymous methods
This CL adds support for promotion of certain private final instance
variables along with anonymous methods. The promotions do not differ
from the ones which are already available in Dart without anonymous
methods, but it requires some generalizations to handle the changing
value of `this` which is made possible by anonymous methods.

Change-Id: I720a5fa6d29a8a7d19bb2e167dc135f97492b525
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498840
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-07 05:39:13 -07:00
Konstantin Shcheglov 0a5604c223 Support for cross-file context messages in test_runner/.
Bug: https://github.com/dart-lang/sdk/issues/63318
Change-Id: Ie02aef92d9ab0e04ce864a85ed6071d5e4b5e14f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500820
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-06 13:23:57 -07:00
mohammadmseet-hue 794b281da3 fix: cap uncompressed WebSocket frame size to prevent peer-induced OOM
Closes https://github.com/dart-lang/sdk/pull/63257

GitOrigin-RevId: 47b50221f808d62c660d855b10cc1f22981c996a
Change-Id: I8c42b12277982caf0da5a627dc8de12102595d0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498460
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-06 04:54:42 -07:00
Johnni Winther a782aed439 [cfe][PrimaryConstructors] Add AsyncModifier
This adds an AsyncModifier class that holds both the AsyncMarker, used in the kernel encoding, and the file offset of the async modifier. This is used throughout the front end and ensures that the correct offset is used for errors reported on the async modifier.

Change-Id: If16d293ffb9b2e8fa8eca8c65f7548d920c5d56b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-06 01:35:05 -07:00
Alexander Aprelev 00cda4d60f [ffi/isolate_group] Move IsolateGroupBound callbacks from isolate to isolate group.
This allows creation of isolategroup-bound callbacks when isolate is not available. For example, to support proposed Isolate::onEvent/Isolate::handleEvent api https://github.com/dart-lang/language/blob/main/working/333%20-%20shared%20memory%20multithreading/shared_native_memory.md#additional-isolate-apis.

BUG=https://github.com/dart-lang/sdk/issues/63291
TEST=isolate_group_bound_callback_test

CoreLibraryReviewExempt: vm ffi-specific comments changes
Change-Id: I9a757a39ba8e152db64f59a66d337ca672103277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499661
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2026-05-05 08:37:06 -07:00
Ivan Ugryumov 6dd8ad5397 Add InterfaceAddress for broadcast address support
Closes https://github.com/dart-lang/sdk/pull/63088

GitOrigin-RevId: c72afbbbf2774fd4c3c3f83b69c30e86e4302abd
Change-Id: I2462f006dcbe2256b019c5b13674ca0d93838fc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/492180
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-05-05 01:15:37 -07:00
mohammadmseet-hue 4d6c9b756c fix: reject Set-Cookie with SameSite=None but no Secure attribute
Closes https://github.com/dart-lang/sdk/pull/63254

GitOrigin-RevId: 18d7d0e46c31783ff200657c0f81d029e9a64231
Change-Id: I3019e7733b6e2a3e1634b6bb7f8bb5e17be35d4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498423
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-05-05 00:53:33 -07:00
Kallen Tu 8bfb683892 Enable 'primary-constructors' feature flag.
This CL enables the primary constructors feature by default in Dart 3.13.

The primary constructors feature is a brevity feature. There are no new semantics, but it allows us to express declarations in a less verbose way.

This feature allows one constructor and a set of instance variables to be specified in the header of a declaration.

Currently a declaration with a constructor and some fields is written as:

```dart
// Current syntax.
class Point {
  int x;
  int y;
  Point(this.x, this.y);
}
```

With a primary constructor, we would write the above as:

```
class Point(var int x, var int y);
```

If a primary constructor needs an initializer list or a body, they can be
specified inside the class using the `this` body syntax:

```dart
class Point(var int x, var int y) {
  this : assert(x >= 0) {
    print('Point created at $x, $y');
  }
}
```

As part of this feature, you can also use the `new` and `factory` keywords to
declare constructors in the class body without repeating the class name:
```dart
class Point {
  int x, y;

  // Equivalent to Point(this.x, this.y)
  new(this.x, this.y);

  // Equivalent to Point.origin()
  new origin() : x = 0, y = 0;

  // Equivalent to factory Point.clone(Point other)
  factory clone(Point other) => Point(other.x, other.y);
}
```

To learn more about the feature, check out the feature specification located here: https://github.com/dart-lang/language/blob/main/accepted/future-releases/primary-constructors/feature-specification.md

Tested: Has existing language, CFE, analyzer, analysis server tests.
Bug: https://github.com/dart-lang/sdk/issues/61524
Change-Id: I296f2fcd918b87bf2a1dd00256340759866c2423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489241
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2026-05-04 15:09:49 -07:00
Paul Berry 9dfa6738c9 Revert "[flow analysis] Fix unsound type promotion in inner async/generator functions."
This reverts commit 3eb697c0af.

Reason for revert: Internal Google3 breakages

Original change's description:
> [flow analysis] Fix unsound type promotion in inner async/generator functions.
>
> An `await` expression or `yield` statement suspends the current
> function and allows other code in the same isolate to execute. In the
> case of nested functions, an `await` or `yield` in the inner function
> can allow the outer function to continue executing. That means that if
> the inner function promotes a local variable belonging to the outer
> function, then it isn't sound to carry that promotion past an `await`
> or `yield`.
>
> This change fixes the unsoundness by adding a flow analysis method
> `suspension`, which the shared type analysis logic uses to tell flow
> analysis that an `await` or `yield` has been found. The `suspension`
> method un-does the promotions of any variables that might be written
> to while the inner function is suspended.
>
> Fixes https://github.com/dart-lang/sdk/issues/62889.
>
> Change-Id: I77eaf997159819a7c50f44b67174d2aa6a6a6964
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499382
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>

Change-Id: I187ba9a347394946ecc8749d35dc7914d271b90a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500540
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2026-05-04 10:37:11 -07:00
Lasse R.H. Nielsen f35a3fcce4 Add alternatives for functions that should be deprecated.
`List.unmodifiable` and `Map.unmodifiable` is as badly typed
as `List.from` and `Map.from`, but does not have a better-typed
`.of` constructor. This adds such, to give a migration target
when deprecating the badly typed constructors.

The `Future.delayed` with no second argument is also unsafely
typed, it fails if the type argument is not nullable.
The `Future.pause` creates `Future<void>` instead.

CoreLibraryReviewExempt: No new or platform specific behavior.
Change-Id: Iba101b3dc62f412003abd501fa042aca0ce63116
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499280
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2026-05-04 08:08:35 -07:00
Paul Berry 3eb697c0af [flow analysis] Fix unsound type promotion in inner async/generator functions.
An `await` expression or `yield` statement suspends the current
function and allows other code in the same isolate to execute. In the
case of nested functions, an `await` or `yield` in the inner function
can allow the outer function to continue executing. That means that if
the inner function promotes a local variable belonging to the outer
function, then it isn't sound to carry that promotion past an `await`
or `yield`.

This change fixes the unsoundness by adding a flow analysis method
`suspension`, which the shared type analysis logic uses to tell flow
analysis that an `await` or `yield` has been found. The `suspension`
method un-does the promotions of any variables that might be written
to while the inner function is suspended.

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

Change-Id: I77eaf997159819a7c50f44b67174d2aa6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499382
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2026-05-01 07:16:25 -07:00
Paul Berry 07b9707d96 [front end] Perform hoisting after coercion.
Coercion from `dynamic` to a non-top type has observable effects,
since it may throw an exception. Therefore it's important that any
tree manipulations that are performed as part of type inference (such
as hoisting of named arguments that precede unnamed ones) preserve the
order of coercions relative to expression evaluation.

Prior to this change, the following code:

    f(n: e1, e2)

Would get transformed into:

    let tmp = e1 in f(coerce(e2), n: coerce(tmp))

And so the coercion of e1 would not happen until after the evaluation
of e2.

With this change, the code is transformed into:

    let tmp = coerce(e1) in f(coerce(e2), n: tmp)

Which (correctly) coerces e1 before evaluating e2.

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

Change-Id: Iee33c162c7cc3a9b0a8b03bde211bf926a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498980
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-30 11:05:39 -07:00
mohammadmseet-hue c5d23e0df3 fix: HTTP request smuggling via Transfer-Encoding token whitespace
Closes https://github.com/dart-lang/sdk/pull/63250

GitOrigin-RevId: 7c6b7bf7d033dd31dc23a7cc3a30b3dc4db41d16
Change-Id: I573328660bbef7ec9cd829ec376fcee894a6bc34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498420
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-30 00:52:02 -07:00
mohammadmseet-hue 890f7e8aa9 fix: do not forward Authorization/Cookie to subdomains on redirect
Closes https://github.com/dart-lang/sdk/pull/63256

GitOrigin-RevId: 1cf4d94690343b4df087e7c583154a36580fff71
Change-Id: I186e9338e36ee72714d385444e6fbf3b217ec4ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498424
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-29 00:54:05 -07:00
Martin Kustermann b8b0cad67a [dart2wasm] Make most void functions have no return values
This gives around 0.2% improvement in compressed e main module.

In Dart a function with `void` return type can actually return values
that callers can observe. But most of the time this doesn't happen, most
times those functions return `null` values and callers don't observe
them.

Let's use inferred return value information to see if a function is
guaranteed to only return `null`. If so we make the wasm function
signature not return any values. Callers will then synthesize a `null`
which may immediatly be dropped or (in rare cases) actually be used.

This leads to less less instructions in the callee (as a callee doesn't
need to push the null onto the stack) and the caller (as the caller
doesn't have to drop it from the stack).

Change-Id: I3ed1be7592798ad0c697c5bc3ab2c4b64c156f03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497620
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-04-28 00:20:02 -07:00
mohammadmseet-hue 75479bc7a7 fix: reject HTTP requests with Transfer-Encoding not ending in chunked
Closes https://github.com/dart-lang/sdk/pull/63251

GitOrigin-RevId: 55ef08553ee65ab1052a46b92ff57f097863c340
Change-Id: Ibd3e93b553e046962bba36ec683b0d2bb157b264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498401
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-27 23:59:39 -07:00
Srujan Gaddam 94e1217774 Reland "[dart:js_interop] Make JSFunction and JSExportedDartFunction generic"
This is a reland of commit e7dbd6ba48

Original change's description:
> [dart:js_interop] Make JSFunction and JSExportedDartFunction generic
>
> Fixes https://github.com/dart-lang/sdk/issues/54557
>
> The generic type in JSExportedDartFunction corresponds to the
> static type of the function it wrapped, whereas for JSFunction,
> it's purely a descriptor of the JS function.
>
> When calling JSExportedDartFunction, a cast is now introduced
> to cast it to T.
>
> When calling isA, the type in JSExportedDartFunction is passed
> along to check that the value that is wrapped is that function
> type. Because the T in JSFunction is descriptive, e.g.
> isA<JSFunction<int Function()>>() does no such check.
>
> ____
>
> Also cleans up:
>
> - isA<JSTypedArray>() logic to use intrinsic functions
> - some expectation files to be consistent for both dart2js and ddc.
>
> CoreLibraryReviewExempt: Backend-specific library with needed reviews.
> Change-Id: I1a55c4386e416fa4ccabe06ac5051f41c2e2e95a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496820
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

CoreLibraryReviewExempt: Reland.
Change-Id: I29d706aa4967fd80390e8cb37f8144603ec007f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498100
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-04-27 20:32:55 -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
Simon Binder 03fd5927a4 [dart2wasm, standalone]: Avoid importing js-string constants
dart2wasm imports strings as globals for which JavaScript engines would
provide the respective values. The standalone target needs to support
all WebAssembly runtimes, so it can't rely on this mechanism.

Instead, this imports functions to convert a WebAssembly arrays of char
codes or ASCII bytes into a string. For now, these functions have to
return JS strings since the rest of the SDK relies on that. In the
future, embedders would be able to return any string implementation as
an externref.

Because calling host functions is invalid in constant contexts, string
constants can't be regular globals. For now, this uses the default
non-eager constant implementation with one initialization function per
string constant. Eventually, we should probably initialize these
strings in a WASM start function instead.

TEST=pkg/dart2wasm/test/standalone_test.dart
Change-Id: I93b7c3846fbe99daa8ffa31e452f62672b61ce4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495020
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-04-24 10:49:11 -07:00
Kallen Tu 77cf3047a3 Dot Shorthands: Const selector chains.
I changed the parsing of const dot shorthands to parse the entire selector chain in `parsePrecedenceExpression` rather than parsing them in `parseConstExpression`. We were originally parsing the initial expression before the `.` and only flagging that as a dot shorthand which prevented any chaining on const constructors. Const expressions with chained methods/property accesses were not being flagged as a dot shorthand so we weren’t saving the context type properly which led to producing the “unknown context type” error.

Before:
```
class C {
  const new someConstCtor();
  C method() => this;
}

C c = const .someConstCtor.method();
// (const .someConstCtor) is parsed and handled as a const constructor
// (const .someConstCtor) is handled as a dot shorthand, context is
// saved on only this AST and not the outer chain.
// Then we parse the rest of the selector chain (.method())
//
// Error: No context type for (const .someConstCtor.method())
```

After:
```
class C {
  const new someConstCtor();
  C method() => this;
}

C c = const .someConstCtor.method();
// (const .someConstCtor) is parsed and handled as a const constructor.
// Then we parse the rest of the selector chain (.method())
// (const .someConstCtor.method()) is handled as a dot shorthand, context is saved for this outer node.
//
// OK. No error because we are able to retrieve the type for the
// entire dot shorthand chain.
```

Fixes: https://github.com/dart-lang/sdk/issues/63119
Change-Id: I3308d8eb7ce101466be257aba6b5448921bff136
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495560
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-04-24 10:40:26 -07:00
Srujan Gaddam 442bdeda4a Revert "[dart:js_interop] Make JSFunction and JSExportedDartFunction generic"
This reverts commit e7dbd6ba48.

Reason for revert: Broke flutter_analyze

Original change's description:
> [dart:js_interop] Make JSFunction and JSExportedDartFunction generic
>
> Fixes https://github.com/dart-lang/sdk/issues/54557
>
> The generic type in JSExportedDartFunction corresponds to the
> static type of the function it wrapped, whereas for JSFunction,
> it's purely a descriptor of the JS function.
>
> When calling JSExportedDartFunction, a cast is now introduced
> to cast it to T.
>
> When calling isA, the type in JSExportedDartFunction is passed
> along to check that the value that is wrapped is that function
> type. Because the T in JSFunction is descriptive, e.g.
> isA<JSFunction<int Function()>>() does no such check.
>
> ____
>
> Also cleans up:
>
> - isA<JSTypedArray>() logic to use intrinsic functions
> - some expectation files to be consistent for both dart2js and ddc.
>
> CoreLibraryReviewExempt: Backend-specific library with needed reviews.
> Change-Id: I1a55c4386e416fa4ccabe06ac5051f41c2e2e95a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496820
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Commit-Queue: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I98447c8c95906feb7f8f1a57859a24fc8e4966d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498080
Commit-Queue: Alexander Aprelev <aam@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Bot-Commit: rubber-stamper@appspot.gserviceaccount.com <rubber-stamper@appspot.gserviceaccount.com>
2026-04-24 09:31:08 -07:00
Srujan Gaddam e7dbd6ba48 [dart:js_interop] Make JSFunction and JSExportedDartFunction generic
Fixes https://github.com/dart-lang/sdk/issues/54557

The generic type in JSExportedDartFunction corresponds to the
static type of the function it wrapped, whereas for JSFunction,
it's purely a descriptor of the JS function.

When calling JSExportedDartFunction, a cast is now introduced
to cast it to T.

When calling isA, the type in JSExportedDartFunction is passed
along to check that the value that is wrapped is that function
type. Because the T in JSFunction is descriptive, e.g.
isA<JSFunction<int Function()>>() does no such check.

____

Also cleans up:

- isA<JSTypedArray>() logic to use intrinsic functions
- some expectation files to be consistent for both dart2js and ddc.

CoreLibraryReviewExempt: Backend-specific library with needed reviews.
Change-Id: I1a55c4386e416fa4ccabe06ac5051f41c2e2e95a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496820
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-04-23 20:55:26 -07:00
Simon Binder 0ae4f93e29 [dart2wasm,standalone] Split patch files by whether they use JS interop
This is a re-land of 152cc24, which has been reverted in 3f9ae7. Unlike
the original change, this doesn't alter the `dart:_wasm` library.
We can revisit an API split to remove `js_interop` APIs there once the
standalone target has progressed further.

Original change's description:
> [dart2wasm] Split patch files by whether they use JS interop
>
> The eventual goal of the `dart2wasm_standalone` platform is to not rely
> on a JavaScript environment, which requires rewriting everything that
> currently relies on `js_interop` or `JS()` helpers.
>
> Since most of the patches are still written in Dart and we don't want
> to duplicate that code for the standalone target, this splits patch
> files by whether they rely on JS-interop or not. The main entrypoint
> for each patch (e.g. `lib/_internal/wasm/lib/core_patch.dart`) no
> longer relies on JS-interop and can safely be used in the standalone
> target. Part files that previously needed to use JS-interop have been
> moved into separate patches now, which allows us to migrate them
> incrementally.
>
> In some cases, it was easier to add new patch files:
>
> - Similar to the split between `boxed_int` and the `toString` helper
>   patch, we now have the same for `boxed_double`.
> - The functionality to copy from JS typed data wrappers into Dart typed
>   lists wouldn't work with standalone, so I've moved it into a separate
>   method we can patch to be a noop.
> - `dart:_wasm` exposes APIs to convert between `JSAny` and `externref`.
>   This is part of a public API, but I had to move those declarations
>   into a patch file because they wouldn't work with standalone.
>   Arguably, a separate library (`dart:_wasm_js_interop`?) would be
>   cleaner but it might be fine as long as `dart:_wasm` is experimental?
>
> For now, new patch files relying on JS interop are also applied to the
> standalone target. They are marked with a comment indicating that they
> need to be migrated though.

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try
Change-Id: I98a628f96cba7e0f0af7e86e058cda43c2c73898
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495302
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2026-04-22 23:54:32 -07:00
Paul Berry 8d59e904e4 [anonymous methods] Test private field promotion.
To work properly with anonymous methods, the private field promotion
logic in flow analysis will have to be updated so that it understands
that `this` refers to a different object inside of an anonymous
method.

This CL adds new language tests to validate that this logic has been
properly updated.

Change-Id: I4ad2c289c5b39bb7397e68eff74324226a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496720
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-04-22 10:19:04 -07:00
Paul Berry 46e2cfe3fd [anonymous methods] Test that super can't be used in parameterless anonymous methods.
Change-Id: Icf5ccff095e42a6e8c151b31c741aec96a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497061
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2026-04-22 07:19:04 -07:00
Lasse R.H. Nielsen ab434651fa Fix cookie-date parsing to use the correct algorithm.
A prior parser change made the parsing more restrictive,
only accepting the dart formats that a cookie creator should
produce, rather than what the RFC specifies should be accepted.

Now implements the specified algorithm again.

Bug: https://github.com/dart-lang/sdk/issues/62721

Prior over-optimisitc breaking change: https://dart-review.googlesource.com/c/sdk/+/448383

Change-Id: I4ed7cf2368d04063e0fc563ff8e64904bf0d3e1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-04-22 06:13:58 -07:00
Erik Ernst e05ce41c0d Add anonymous => method related implementation in the CFE
This CL adds an implementation of anonymous `=>` methods in the CFE
which is sufficiently complete to handle the existing test cases in
language/anonymous_methods/expression.

Coverage is handled by adding magic comments to ignore the fact that new
code is not covered by existing testcases. This will be settled in a
separate CL.

To keep the failures visible, the failures in configurations
dart2js-hostasserts-linux-d8-try, dart2js-linux-chrome-try,
dart2js-minified-linux-d8-try, and ddc-linux-chrome-try have not been
approved. It seems likely to me that those are bugs in dart2js and in
DDC.

Change-Id: Ia70fedd4de6166d6a3bf8a108f49728b6e16c9f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494440
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-21 02:09:41 -07:00
Martin Kustermann 12174830ec [dart2wasm] Optimize the way we implement constructors
This reduces essentials main module around -0.4% and possibly
opens up for changes in the inlining (specifically to possibly
not force-inline all initializers anymore)

This shrinks the amount of information
* initializer result values
* the body parameters
* the allocator needs to forward less from initializer to body

We do that by analyzing constructor parameters to see
which parameters are needed for the constructor

Change-Id: I967fa4102ea6e9d498ff07aedabc368b038e1085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496341
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-04-21 00:13:42 -07:00
Sergey G. Grekhov 8f1336e49e [co19] Roll co19 to d7f69e054e32444b634f4eed5ceec15eb3432ddb
2026-04-17 sgrekhov22@gmail.com Fixes dart-lang/co19#3742. Don't use primary constructors in typedef_A01_t03.dart (dart-lang/co19#3743)
2026-04-17 sgrekhov22@gmail.com Fixes dart-lang/co19#3740. Fix expected result in grammar_A05_t09.dart (dart-lang/co19#3741)
2026-04-16 sgrekhov22@gmail.com dart-lang/co19#3698. Update tests for `return` statement. Part 3. (dart-lang/co19#3706)
2026-04-16 sgrekhov22@gmail.com Fixes dart-lang/co19#3737. Update tests for named parameters whose names start with _. (dart-lang/co19#3738)
2026-04-16 sgrekhov22@gmail.com dart-lang/co19#3709. Fix some of failing TypeSystem tests (dart-lang/co19#3736)
2026-04-15 sgrekhov22@gmail.com dart-lang/co19#3709. Add more tests for named optional parameters (dart-lang/co19#3735)
2026-04-15 sgrekhov22@gmail.com Fixes dart-lang/co19#3730. Fix co19 tests according to Dart 3.13 syntax. Part 2. (dart-lang/co19#3733)
2026-04-14 sgrekhov22@gmail.com dart-lang/co19#3315. Add more tests for factory constructors (dart-lang/co19#3734)
2026-04-13 sgrekhov22@gmail.com Fixes dart-lang/co19#3730. Fix co19 tests according to Dart 3.13 syntax (dart-lang/co19#3732)

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

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try
Change-Id: If6a727d195b0cd3b267cc3eb8a7d57726b8cfcd7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496580
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-04-20 02:58:23 -07:00
Konstantin Shcheglov 6cd3938741 Breaking changes for analyzer 13.0.0
https://github.com/dart-lang/sdk/issues/62799
https://github.com/dart-lang/sdk/issues/62944
https://github.com/dart-lang/sdk/issues/63002
https://github.com/dart-lang/sdk/issues/62970

Looks mostly green in google3: https://fusion2.corp.google.com/presubmit/901021300/OCL:901021300:BASE:901308428:1776439417713:37cd1695

Change-Id: I44754a48f66a0b58851d7c20fcfa61f7fb1b555a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/488624
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-04-17 23:06:25 -07:00
Kallen Tu 1c7332ec86 [tests] Primary constructors: Enums have implicitly const constructors.
Added a single test for this new change.
Tested with new and old constructor syntax.

Bug: https://github.com/dart-lang/language/issues/4494
Change-Id: I8cda70398fb1d7de17f41fc541edaf8f16490a8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495580
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-04-16 11:56:05 -07:00
kyungilcho 316092eabb [dart2wasm] Avoid redundant typed_data buffer allocations in setRange
Closes https://github.com/dart-lang/sdk/pull/63151

GitOrigin-RevId: 17ee4021c13e74c681a3a95083eb6fdd169ae804
Change-Id: Ic62951a8a8c9c7d7cb5952a31905ad1f20b1a7d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-04-16 05:06:38 -07:00
Johnni Winther 1d40001a98 [cfe][PrimaryConstructors] Don't remove const modifier
This stops the practice of removing the const modifier from const constructors with a body. Since primary constructor introduces more complex scenarios of this problem space, retaining the constness seems to have better results in terms of cascading errors. In particular, not reporting that a non-const constructor cannot be invoked when it is actual a const (alas erroneous) constructor.

Change-Id: I33b3982ec0fce89946f8700f98bf08161d930d36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-04-15 03:08:56 -07:00
Slava Egorov 3f9ae74880 Revert "[dart2wasm] Split patch files by whether they use JS interop"
This reverts commit 152cc247e0.

Reason for revert: Broken web_ui analysis (see flutter-analyze)

Original change's description:
> [dart2wasm] Split patch files by whether they use JS interop
>
> The eventual goal of the `dart2wasm_standalone` platform is to not rely
> on a JavaScript environment, which requires rewriting everything that
> currently relies on `js_interop` or `JS()` helpers.
>
> Since most of the patches are still written in Dart and we don't want
> to duplicate that code for the standalone target, this splits patch
> files by whether they rely on JS-interop or not. The main entrypoint
> for each patch (e.g. `lib/_internal/wasm/lib/core_patch.dart`) no
> longer relies on JS-interop and can safely be used in the standalone
> target. Part files that previously needed to use JS-interop have been
> moved into separate patches now, which allows us to migrate them
> incrementally.
>
> In some cases, it was easier to add new patch files:
>
> - Similar to the split between `boxed_int` and the `toString` helper
>   patch, we now have the same for `boxed_double`.
> - The functionality to copy from JS typed data wrappers into Dart typed
>   lists wouldn't work with standalone, so I've moved it into a separate
>   method we can patch to be a noop.
> - `dart:_wasm` exposes APIs to convert between `JSAny` and `externref`.
>   This is part of a public API, but I had to move those declarations
>   into a patch file because they wouldn't work with standalone.
>   Arguably, a separate library (`dart:_wasm_js_interop`?) would be
>   cleaner but it might be fine as long as `dart:_wasm` is experimental?
>
> For now, new patch files relying on JS interop are also applied to the
> standalone target. They are marked with a comment indicating that they
> need to be migrated though.
>
> Change-Id: I583f23f6cc1a3fc7332962292d69f3a7b0327409
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489660
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>

No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Change-Id: I21428bdabcabdbdd07f3453384bb31154083c8aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494920
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-13 10:26:58 -07:00
Paul Berry 25bb8ce922 Add language tests for issues 33298 and 56666.
Yesterday I discovered some code in the front end type inference
engine that I didn't expect: logic that added constraints to type
inference based on the result of applying type coercions. To figure
out why it was necessary, I disabled it and ran the code through
trybots. It turns out that it's needed to prevent the following
issues:
- https://github.com/dart-lang/sdk/issues/33298
- https://github.com/dart-lang/sdk/issues/56666

Fortunately, we had regression tests for these issues:
- `pkg/front_end/testcases/general/bug33298.dart`
- `pkg/front_end/testcases/general/issue56666.dart`

Unfortunately, those regression tests are front-end specific, meaning
we didn't have any coverage for the analyzer.

This CL adds coverage for the analyzer by replicating the regression
tests in `tests/language`.

Change-Id: Ia53b3c898549e991d6685a414d177a466a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494563
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-04-13 09:30:21 -07:00
Sergey G. Grekhov 256878a672 [co19] Roll co19 to 4d90df49d4fc0d9aef3d3a0aed2bc0473fde81ef
2026-04-13 sgrekhov22@gmail.com dart-lang/co19#3315. Add missing experimental flag to `Language/Functions/Formal_Parameters/Optional_Formals/` tests (dart-lang/co19#3731)
2026-04-13 sgrekhov22@gmail.com dart-lang/co19#3203. Add VM debugger test for primary constructors of extension types (dart-lang/co19#3684)
2026-04-10 sgrekhov22@gmail.com Fixes dart-lang/co19#3728. Fix typos in syntax_t02.dart (dart-lang/co19#3729)
2026-04-10 sgrekhov22@gmail.com Fixes dart-lang/co19#3723. Add more tests for constants and ternary operator (dart-lang/co19#3724)
2026-04-10 sgrekhov22@gmail.com dart-lang/co19#3315. Add tests for `var` and `final` parameters of operators (dart-lang/co19#3727)
2026-04-10 sgrekhov22@gmail.com Fixes dart-lang/co19#3719. Update test in Language/Expressions/Bitwise_Expressions (dart-lang/co19#3720)
2026-04-10 sgrekhov22@gmail.com Fixes dart-lang/co19#3725. Fix the new roll failures (dart-lang/co19#3726)
2026-04-10 sgrekhov22@gmail.com dart-lang/co19#3315. Fix tests that use obsolete var syntax. Part 24. (dart-lang/co19#3721)
2026-04-10 sgrekhov22@gmail.com Fixes dart-lang/co19#3717. Fix expected error location in parameter_A06_t02.dart (dart-lang/co19#3722)
2026-04-09 sgrekhov22@gmail.com dart-lang/co19#3709. Fix failing tests, add issues numbers. Part 3. (dart-lang/co19#3718)
2026-04-08 sgrekhov22@gmail.com dart-lang/co19#3315. Fix tests that use obsolete var syntax. Part 23. (dart-lang/co19#3716)
2026-04-08 sgrekhov22@gmail.com Fixes dart-lang/co19#3714. Updated tests in `Language/Functions/Formal_Parameters/Optional_Formals` (dart-lang/co19#3715)
2026-04-07 sgrekhov22@gmail.com dart-lang/co19#3709. Fix failing tests, add issues numbers (dart-lang/co19#3710)
2026-04-07 sgrekhov22@gmail.com Fixes dart-lang/co19#3707. Add more tests for `continue` statement (dart-lang/co19#3708)
2026-04-07 sgrekhov22@gmail.com dart-lang/co19#3698. Update tests for `return` statement. Part 2. (dart-lang/co19#3705)
2026-04-07 sgrekhov22@gmail.com dart-lang/co19#3709. Fix failing tests, add issues numbers. Part 2. (dart-lang/co19#3712)
2026-04-07 sgrekhov22@gmail.com Fixes dart-lang/co19#3711. Update expected error location in static_processing_A03_t02.dart (dart-lang/co19#3713)
2026-04-01 sgrekhov22@gmail.com Fixes dart-lang/co19#3315. Add tests for metadata (dart-lang/co19#3704)
2026-04-01 sgrekhov22@gmail.com dart-lang/co19#3182. Add more tests for augmenting parameter with name `_`. Part 2. (dart-lang/co19#3697)
2026-04-01 sgrekhov22@gmail.com Fixes dart-lang/co19#3702. Fix/expect secondary errors in `grammar_A03_t02.dart` (dart-lang/co19#3703)
2026-04-01 sgrekhov22@gmail.com dart-lang/co19#3315. Add tests for primary constructors of mixin class (dart-lang/co19#3701)
2026-03-31 sgrekhov22@gmail.com dart-lang/co19#3315. Add tests for the syntax and for constant primary constructors (dart-lang/co19#3700)
2026-03-31 sgrekhov22@gmail.com dart-lang/co19#3698. Update tests for `return` statement. Part 1. (dart-lang/co19#3699)
2026-03-30 sgrekhov22@gmail.com dart-lang/co19#3182. Add more tests for augmenting parameter with the name `_` (dart-lang/co19#3696)
2026-03-30 sgrekhov22@gmail.com dart-lang/co19#3182. Revert tests for augmenting parameter with the name `_` (dart-lang/co19#3695)

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

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try
Change-Id: I1f57467f4665f37b301db3df3d8934db10afd695
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494820
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-04-13 08:16:43 -07:00
Simon Binder 152cc247e0 [dart2wasm] Split patch files by whether they use JS interop
The eventual goal of the `dart2wasm_standalone` platform is to not rely
on a JavaScript environment, which requires rewriting everything that
currently relies on `js_interop` or `JS()` helpers.

Since most of the patches are still written in Dart and we don't want
to duplicate that code for the standalone target, this splits patch
files by whether they rely on JS-interop or not. The main entrypoint
for each patch (e.g. `lib/_internal/wasm/lib/core_patch.dart`) no
longer relies on JS-interop and can safely be used in the standalone
target. Part files that previously needed to use JS-interop have been
moved into separate patches now, which allows us to migrate them
incrementally.

In some cases, it was easier to add new patch files:

- Similar to the split between `boxed_int` and the `toString` helper
  patch, we now have the same for `boxed_double`.
- The functionality to copy from JS typed data wrappers into Dart typed
  lists wouldn't work with standalone, so I've moved it into a separate
  method we can patch to be a noop.
- `dart:_wasm` exposes APIs to convert between `JSAny` and `externref`.
  This is part of a public API, but I had to move those declarations
  into a patch file because they wouldn't work with standalone.
  Arguably, a separate library (`dart:_wasm_js_interop`?) would be
  cleaner but it might be fine as long as `dart:_wasm` is experimental?

For now, new patch files relying on JS interop are also applied to the
standalone target. They are marked with a comment indicating that they
need to be migrated though.

Change-Id: I583f23f6cc1a3fc7332962292d69f3a7b0327409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/489660
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-04-13 03:44:43 -07:00
Erik Ernst 56df2ae167 Adjust flow analysis to handle break/continue in an anonymous method
This CL changes the flow analysis slightly such that the analyzer is
able to handle a `break;`, `break L;`, `continue;`, or `continue L;`
that occurs in the body of an anonymous method. It adds a test for a few
situations where this feature is used.

Change-Id: I5b065a6ad96e346502fd071d1547ccd143f37e80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/491800
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-04-13 01:06:01 -07:00
Srujan Gaddam ef6054d688 Update Chrome to 148.0.7778.5
Also updates a few tests due to changes in how createEvent
can be used. That browser API has been deprecated for a long
time, but only recently did Chrome remove support for
PopStateEvent through that API. So, instead to retain the
original intent of the test, confuses are added after
constructing the event to check that type tests work correctly.

A few other tests are modified to remove code that depends on
createEvent, either through eventType or supported members.

See the Chrome bug for more details on the removal:
https://issues.chromium.org/issues/41228793#comment38

Change-Id: Id55a215583221de3ccdbbeff16a2e17e9e35fb0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494160
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
2026-04-10 09:24:12 -07:00