Commit Graph

24193 Commits

Author SHA1 Message Date
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
Kevin Moore 26fa4add14 dart2wasm: tool cleanup
DRY'd up some helpers and logic
Deleted validate_wasm_test.sh
Added `--run` and `--write-temp` flags to compile_benchmark

Change-Id: I666b25d13d0837a2b9f9fc40488882f1cfc6aff5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478703
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
2026-02-18 19:16:22 -08:00
Robert Nystrom c82716b216 Enable "private-named-parameters" experiment flag.
TEST=many language, co19, and other tests

Bug: https://github.com/dart-lang/sdk/issues/61629
Change-Id: I24d761cc2dc3fa2707a2486a39bfde1b8e847b1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480384
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2026-02-18 15:26:18 -08:00
Ryan Macnak eae5349c23 [test] Remove asserts that currentRss <= maxRss.
The underlying syscalls and proc reads that produce these values may produce inaccurate values.

Bug: https://github.com/dart-lang/sdk/issues/62715
Change-Id: I508db7722a4ab2536848742155ef5631533b58dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/481580
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2026-02-18 14:26:51 -08:00
Kevin Moore e0b028808a [dart2wasm] Expand Wasm SIMD intrinsics for vector operations
Add more Wasm SIMD intrinsics and instructions to support efficient
vector operations, specifically targeting the requirements of types
like Offset and Size.

- Implement new intrinsics in `dart2wasm`:
  - `anyTrue` for V128.
  - `allTrue` for I64x2.
  - `pmin`/`pmax` (pseudo-minimum/maximum) for F64x2.
  - `fromLaneValues` for F32x4 and F64x2.
  - `shuffle` for F64x2.
- Update `wasm_builder` with support for the following instructions:
  - `v128.any_true`
  - `i8x16.all_true`, `i16x8.all_true`, `i32x4.all_true`, `i64x2.all_true`
  - `i8x16.shuffle` (including serialization and deserialization)
- Add `tests/web/wasm/simd/vector_test.dart`, which implements `Offset`
  and `Size` using these new SIMD intrinsics, demonstrating their
  practical utility and correctness.
- Update `tests/web/wasm/simd/simd_test.dart` with additional coverage.

Change-Id: Ifa5ba0fb265b0fa46c0a3469d9331f32a025c9ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478860
Commit-Queue: Kevin Moore <kevmoo@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-02-17 16:05:32 -08:00
Lasse R.H. Nielsen 6fe105671c Remove var and final from parameters in test/.
Not removing from any file with a language marker.
Also not touching anything in `tests/language/primary_constructors`
or `.../private_named_parameters`, which are both assumed to be
primary constructor feature aware.

Two files rewritten from multi-test to error-test.

Change-Id: I43d444a35a41c7734f266794e9f167655692473f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480640
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2026-02-17 08:28:57 -08:00
Martin Kustermann 8ee6ee4881 [dart2wasm] Fix issue of copying mixin applications with deferred prefix access
If a mixin application class gets copies of the members of a mixin, the
copies may reside in a different library. That means the copied member
body's references to import prefixes are "dangling" (or "pointing" to a
prefix of a different library).

We had a fast case: If there's no deferred import in a library we didn't
visit the body to lower `CheckLibraryIsLoaded` AST nodes.

=> We remove this optimization which will fix the bug.
=> Long term libraries may be allowed to refer prefixes of other
libraries (as part of work on [0])

[0] https://github.com/dart-lang/sdk/issues/61764

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

Change-Id: I74e81418ff2df176ff5481ea36f3b68ab3df4d4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480940
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-02-17 00:03:26 -08:00
Sergey G. Grekhov a230c056d2 [co19] Roll co19 to ac779cf0ef7215bc226d00af16f31fe35b1850f5
2026-02-12 sgrekhov22@gmail.com dart-lang/co19#3182. Fix/update tests for primary constructors (dart-lang/co19#3616)
2026-02-11 sgrekhov22@gmail.com dart-lang/co19#3182. Add tests for augmentation of primary constructors. Part 2. (dart-lang/co19#3611)
2026-02-11 sgrekhov22@gmail.com Fixes dart-lang/co19#3612. Replace WARNING.X_Y_Z by STATIC_STATIC_WARNING.X_Y_Z (dart-lang/co19#3613)
2026-02-10 sgrekhov22@gmail.com dart-lang/co19#3608. Update primary constructor tests (dart-lang/co19#3610)
2026-02-10 sgrekhov22@gmail.com dart-lang/co19#3182. Add tests for augmenting primary constructors (dart-lang/co19#3606)
2026-02-10 sgrekhov22@gmail.com dart-lang/co19#3182. Remove duplicated tests for extension types (dart-lang/co19#3609)
2026-02-09 sgrekhov22@gmail.com dart-lang/co19#3182. Add tests for augmentation of primary constructors (dart-lang/co19#3607)
2026-02-06 sgrekhov22@gmail.com dart-lang/co19#3182. Update `extension_types_*.dart` tests (dart-lang/co19#3462)
2026-02-06 sgrekhov22@gmail.com dart-lang/co19#3182. Add new test for `async`, `async*` and `sync*` functions (dart-lang/co19#3568)
2026-02-06 sgrekhov22@gmail.com dart-lang/co19#3602. Add more tests for primary constructors (dart-lang/co19#3603)

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

Cq-Include-Trybots: luci.dart.try:analyzer-linux-release-try,dart2js-minified-linux-d8-try
Change-Id: I42f2f90acd34e02bc8ecdae34ee1b46bf699a2c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480920
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-02-16 09:17:41 -08:00
Martin Kustermann b87dd83013 [dart2wasm] Fix bug in handling of forwarding stubs to fields
The CFE may insert forwarding stubs not only for procedures
but also for fields that require covariance type checks on
the setter values.

This also fixes a bug where type parameter bounds weren't
correctly type checked against (The VM has the same bug, see [1])

[0] https://github.com/dart-lang/sdk/issues/62664

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

Change-Id: I61c005a26bd393df3279fdb349304ccc1eec9c6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480200
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2026-02-13 11:56:53 -08:00
Konstantin Shcheglov 7d703f75fc CQ. Fix scoping of for-loop variables in initializers
Ensure loop-local variables introduced by `for` parts are bound
consistently during resolution, while still reporting reads that occur
before the declaration point.

The resolver now predeclares `ForPartsWithDeclarations` variables in the
loop’s local scope before traversing the initializer/condition/updaters.
This makes lexical lookup within `forLoopParts` resolve to the
loop-local element (even in `var x = x`), and allows later verification
to correctly report `REFERENCED_BEFORE_DECLARATION` instead of treating
the name as outer/undefined.

Also align foreach resolution by defining the declared loop variable
only after visiting the iterable expression, and update error
verification to hide not-yet-declared elements consistently for blocks,
switch members, and `for` parts via a generalized
`HiddenElements.forElements` helper.

Change-Id: Ifab327737bb033fe05f1d765196796924378ac5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/480120
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-02-12 13:50:24 -08:00
Konstantin Shcheglov 51c059c43b CQ. Start using InstanceScope in ResolutionVisitor, a little.
The previous implementation was using LocalScope that does not do
filtering out instance members as required by the specification.

I also added a few tests, some of which demonstrate what was worked,
what was broken, and what is still broken.

Work toward fixing https://github.com/dart-lang/sdk/issues/62622

Change-Id: Ib5fa23b97d1e6938eb00a2d2b6659eecae86b3b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479380
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-02-12 13:02:56 -08:00